// ==UserScript==
// @name           Power Tools - Deutsch
// @namespace      PDX
// @description    KoC Power Tools - German Version by PDX
// @homepage      http://koc.god-like.org
// @version       0.4.8
// @include        *apps.facebook.com/kingdomsofcamelot*
// @include        http://*.kingdomsofcamelot.com/*main_src.php*
// @icon         http://koc.god-like.info/pdx.jpg
// @resource       URL_CASTLE_BUT          http://koc.god-like.info/schloss1.png
// @resource       URL_CASTLE_BUT_SEL       http://koc.god-like.info/schloss2.png
// @resource       URL_PROVINCE_MAP       http://koc.god-like.info/karte.png
// @require        http://koc.god-like.info/update/kocpowertoolsdeutsch.php?id=98323
// ==/UserScript==

var Version = '0.4.8';

var Title = 'KoC Power Tools - Deutsch';
var DEBUG_BUTTON = true;
var DEBUG_TRACE = false;
var DEBUG_TRACE_DRAG = false;
var DEBUG_TRACE_AJAX = false;
var MAP_DELAY = 1500;
var DISABLE_POST_KNIGHT_SKILLS = false;
var DISABLE_POST_DEFENSES = false;
var ENABLE_TEST_TAB = true;
var SEND_ALERT_AS_WHISPER = false;
var TEST_WIDE = false;
var TEST_WIDE_CITIES = 7;
var ENABLE_SEARCH_TAB = true;

var URL_CASTLE_BUT = "%2F%2F8X%2F98X%2F973%2F97X%2F77X%2F7633773%2F76X377X3763%2F5q3%2F5qX%2F5pz35q335qX%2F3pz%2F3pT33pz%2F1pT%2F1oz%2F1oT31pT31oz%2FzoT%2Fznv3zoT%2FxXv%2FxXP%2FxWv3xXv3xXP%2FvWv%2FvWP3vWv3vWP%2FtWP%2FtVr%2FtVLmvWv3tWP3tVr3tVL%2FrVL%2FrUrmtWP3rVL3rUrvrVL%2FpUrvrUr%2FpULmrVrmrVL3pUr3pULmpUL3nDrepULWpVLWpUrmnDrFpUK1pVrOnDqcnFKcnEqMnEp7lHN7lGtzlGNrlGtjjEpajFpShFJSe2NChEJKe1o6hDohjDFCc1oZjDEhhDEQjDEAlDEpezoZhDEhezoQhDEAjDEpczoZezoIhDEhc0IhczoAhDEZczoIezEhazoAezEhY0IAczEAcykI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kDgO6lOcWjZdSMFSi8ZADr2CtxWK9GGZrVwBoIZYYKy5QWbMmHQSyZm0MQw0rcRWEydfvXJMHIXYloMaaOEgitYrj81LwRQ2swlAMcUmcKxspMWuOTJEDri0UHYr7ybBEqIQdP%2B%2FUALn13NcVZ8dW6iDpRNy2lQbgAFsvb6Ua5OotLvwigdwMlSNvTvH5xOjIYR4nTvs4dejLAUzXjh289t3bK3pvPV43d%2FTUr1OsPfG9c%2FXzv5uMDxP49%2Fu1AwIAOw%3D%3D";
var provMapCoords = {imgWidth:710, imgHeight:708, mapWidth:670, mapHeight:670, leftMargin:31, topMargin:19};  

/***************
2011...
*) Players tab: added online status
*) Train tab: minor cosmetic changes
*) Train tab: show limiting resource in red
*) Train tab: allow cancel
*) Overview tab: Added display options
*) Overview tab: Added option to include troops in training
*) KOC version and debug button moved to info tab
*) Fix fwd/all officers button ???
*) Remember currently selected march tab on refresh
*) Changed image URLs to embedded data

TODO: New Marches tab
TODO: Search Tab ETA einfügen!

***************/

/******************
// TODO: ptGotoMap ... (WinManager.hideAll())
// TODO: Food surplus trend (% change over 30 minutes, etc.)
// TODO: Force KOC to update training queues, marches, etc for non-current city ?  (fix 'waiting for reports', lingering tower alerts, etc)
// TODO: Buttons to attack, transport, etc. right on the rally point screen. These buttons would effectively select the 'March Troops' tab AND select the march type.
***/

    
var Options = {
  includeMarching:true,
  includeTraining:false,
  encRemaining : true,
  maxIdlePop   : false,
  srcSortBy    : 'level',
  srcMinLevel  : 1,
  srcMaxLevel  : 7,
  wildType     : 1,
  MightSrc     : 1,
  unownedOnly  : true,
  fixTower     : true,
  fixTower2    : true,
  fixMapDistance: true,
  fixMsgCount  : true,
  fixWarnZero  : true,
  fixPageNav   : true,
  enhanceARpts : true,
  allowAlterAR : true,
  enhanceMsging : true,
  ptWinIsOpen  : false,
  ptWinDrag    : false,
  ptWinPos     : {},
  enableFoodWarn : true,
  enableFoodAlert : false,
  foodWarnHours : 24,
  foodAlertHours : 4,
  lastVersion : null,
  hideOnGoto : true,
  currentTab : false,
  gmtClock : true,
  chatEnhance : true,
  fixKnightSelect : true,
  attackCityPicker : true,
  mapCoordsTop : true,
  dispBattleRounds : true,
  reportDeleteButton : true,
  overviewFontSize : 12,
  overviewAllowOverflow : false,
  curMarchTab : 'A',
  playersNoCities : false,
  alertConfig  : {aChat:false, aPrefix:'!!! ACHTUNG = ANGRIFF !!!', scouting:false, wilds:false, minTroops:10000, spamLimit:10 },
  chatglobal : true,
  chatwhisper : true,
  chatbold : false,
};

var JSON;if(!JSON){JSON={};}(function(){"use strict";function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}if(typeof rep==='function'){value=rep.call(holder,key,value);}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}return str('',{'':value});};}if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}throw new SyntaxError('JSON.parse');};}}());
var JSON2 = JSON;

var Cities = {};
var Seed = unsafeWindow.seed;
var Tabs = {};
var currentName = 'Stats';
var mainPop;
var CPopUpTopClass = 'ptPopTop';
var KOCversion = null;
var ptStartupTimer = null;

function ptStartup (){
  clearTimeout (ptStartupTimer);
  if (unsafeWindow.ptLoaded)
    return;
  var metc = getClientCoords(document.getElementById('main_engagement_tabs'));
  if (metc.width==null || metc.width==0){
    ptStartupTimer = setTimeout (ptStartup, 1000);
    return;
  }
  unsafeWindow.ptLoaded = Version;
  KOCversion = anticd.getKOCversion();
  logit ("KofC client version: "+ KOCversion);
  
  readOptions();

//logit ('g_timeoff: '+ unsafeWindow.g_timeoff);
  Seed = unsafeWindow.seed;
  var gmstyles = '\
    .ptcastleButNon {background-image:url("'+ URL_CASTLE_BUT +'")}\
    .ptcastleButSel {background-image:url("'+ URL_CASTLE_BUT_SEL +'")}\
    .ptcastleBut {outline:0px; margin-left:0px; margin-right:0px; width:24px; height:26px; font-size:12px; font-weight:bold;}\
    .ptcastleBut:hover {border-size:3px; border-color:#000;}\
  ';
  
  var styles = '.xtab {padding-right: 5px; border:none; background:none; white-space:nowrap;}\
    .ptFeindlich td { background:#FF4040; }.ptFreundlich td{background:lightblue; }.ptally td{background:royalblue; }\
    .ptNeutral td { background:#C8C8C8; }.ptAllianzlose td { background:gold; }\
       .Feindlich td { background:crimson; }.Freundlich td{background:lightblue; }.Alliierte td{background:008000; }\
    .Neutral td { background:lightgreen; }.Allianzlose td { background:gold; }\
    .xtabBR {padding-right: 5px; border:none; background:none;}\
    div.ptDiv {background-color:#f0f0f0;}\
    table.ptTab tr td {border:none; background:none; white-space:nowrap;}\
    table.ptTabPad tr td {border:none; background:none; white-space:nowrap; padding: 2px 4px 2px 4px;}\
    table.ptTabBR tr td {border:none; background:none;}\
    table.ptTabLined tr td {border:1px none none solid none;}\
    table.ptTabOverview tr td {border-left:1px solid #ccc; white-space:nowrap; padding: 1px;}\
    table.ptTabPad tr td.ptentry {background-color:#ffeecc; padding-left: 8px;}\
    table.ptNoPad tr td {border:none; background:none; white-space:nowrap; padding:0px}\
    table.ptPlayers tr td {background-color:none; padding-left:5px; padding-right:5px;}\
    .ptOddrow {background-color:#eee}\
    .ptstat {border:1px solid; border-color:#ffffff; font-weight:bold; padding-top:2px; padding-bottom:2px; text-align:center; color:#ffffff; background-color:#357}\
    .ptStatLight {color:#ddd}\
    .ptentry {padding: 7px; border:1px solid; border-color:#000000; background-color:#ffeecc; white-space:nowrap;}\
    .ptErrText {font-weight:bold; color:#600000}\
    button::-moz-focus-inner, input[type="submit"]::-moz-focus-inner { border: none; }\
    .ptChatWhisper {font-weight:bold;color:#FF0000}\
    .ptChatGlobalBold {font-weight:bold}\
    .ptChatGlobalAll {font-weight:bold;background-color:none}\
    .ptChatAlliance {font-weight:bold}\
    .ptChatGlobal {background-color: #fdd}\
    .ptChatIcon {border: 3px inset red}\
    span.whiteOnRed {padding-left:3px; padding-right:3px; background-color:#700; color:white; font-weight:bold}\
    span.boldRed {color:#800; font-weight:bold}\
   span.boldDarkGreen {color:#008000; font-weight:bold}\
    a.ptButton20 {color:#ffff80}\
    hr.ptThin {padding:0px; margin:0px}\
    input.pbSubtab {cursor:pointer; width:10em; margin-right:15px;}\
    input.pbSubtabSel {background-color:#444; color:white; font-weight:bold; cursor:none !important}\
    table.ptMainTab {empty-cells:show; margin-top:5px }\
    table.ptMainTab tr td a {color:inherit }\
    table.ptMainTab tr td   {height:60%; empty-cells:show; padding: 0px 5px 0px 5px;  margin-top:5px; white-space:nowrap; border: 1px solid; border-style: none none solid none; }\
    table.ptMainTab tr td.spacer {padding: 0px 4px;}\
    table.ptMainTab tr td.sel    {font-weight:bold; font-size:13px; border: 1px solid; border-style: solid solid none solid; background-color:#eed;}\
    table.ptMainTab tr td.notSel {font-weight:bold; font-size:13px; border: 1px solid; border-style: solid solid none solid; background-color:#1e66bd; color:white; border-color:black;}\
    tr.ptPopTop td { background-color:#dde; border:none; height: 21px;  padding:0px; }\
    tr.ptretry_ptPopTop td { background-color:#a00; color:#fff; border:none; height: 21px; padding:0px; }\
    input.ptButCancel {background-color:#a00; font-weight:bold; color:#fff}\
    .CPopup .CPopMain { background-color:#f8f8f8; padding:6px;}\
    .CPopup  {border:3px ridge #666} )';
      
  logit ("* KpC Power Tools - Deutsch - by PDX - Version: "+ Version +" geladen!");
  
  
if (TEST_WIDE){
  // max cityname len = 15?
  for(i=0; i<Seed.cities.length; i++){
    Seed.cities[i][1] = Seed.cities[i][1] + 'LONGERNAMETEST';
    Seed.cities[i][1] = Seed.cities[i][1].substr(0,15);
  }
  var numToAdd = TEST_WIDE_CITIES - Seed.cities.length;
  while (numToAdd-- > 0){
    var cityId = Math.random() * 1234567;
    Seed.cities.push (Seed.cities[0]);
  }    
}
  setCities();

// TODO: Make sure WinPos is visible on-screen ?
  if (Options.ptWinPos==null || Options.ptWinPos.x==null|| Options.ptWinPos.x=='' || isNaN(Options.ptWinPos.x)){
//logit ( 'Options.ptWinPos: '+ inspect (Options.ptWinPos, 5, 1));
    var c = getClientCoords (document.getElementById('main_engagement_tabs'));
    Options.ptWinPos.x = c.x+4;
    Options.ptWinPos.y = c.y+c.height;
    saveOptions ();
  }
  mainPop = new CPopup ('ptmain', Options.ptWinPos.x, Options.ptWinPos.y, 749,700, Options.ptWinDrag,
      function (){
        tabManager.hideTab();
        Options.ptWinIsOpen=false;
        saveOptions();
      });

  GM_addStyle (gmstyles);  
  mainPop.getMainDiv().innerHTML = '<STYLE>'+ styles +'</style>';
  FoodAlerts.init();
  TowerAlerts.init();
  MessageCounts.init ();
  MapDistanceFix.init ();
  WarnZeroAttack.init ();
  AllianceReports.init ();
  messageNav.init();
  PageNavigator.init ();
  ChatStuff.init ();
  AttackDialog.init();
  battleReports.init ();
  CoordBox.init ();
  GMTclock.init ();
  tabManager.init (mainPop.getMainDiv());
  
  if (Options.ptWinIsOpen){
    mainPop.show (true);
    tabManager.showTab();
  }
  window.addEventListener('unload', onUnload, false);
  
  if (Options.fixTower)
    TowerAlerts.enableFixTarget(true);
  if (Options.fixTower2)
    TowerAlerts.enableFixFalseReports(true);
  
  AddMainTabLink('Power Tools', eventHideShow, mouseMainTab);
TestSomething.init ();  
//setInterval (function(){logit (inspect (getClientCoords (mainPop.getMainDiv()), 3, 1))}, 2000);  
}


function onUnload (){
  Options.ptWinPos = mainPop.getLocation();
  saveOptions();
}


var knightRoles = [
  ['Meister', 'politics', 'Pol.'],
  ['Marschall', 'combat', 'Schlacht'],
  ['Alchemistisch', 'intelligence', 'Int.'],
  ['Verwalter', 'resourcefulness', 'Ressis'],
];

var CoordBox = {
  init : function (){
    var t = CoordBox;
    t.boxDiv = searchDOM (document.getElementById('maparea_map'), 'node.className=="mod_coord"', 3, false);
    t.setEnable (Options.mapCoordsTop);
  },
  setEnable : function (tf){
    var t = CoordBox;
    if (t.boxDiv == null)
      return;
    if (tf)
      t.boxDiv.style.zIndex = '100000';
    else
      t.boxDiv.style.zIndex = '10011';
  },
  isAvailable : function (){
    var t = CoordBox;
    return !(t.boxDiv==null);
  },
};





var TestSomething = {
  init : function (){
    t = TestSomething;
return;    
    var ft = unsafeWindow.modal_messages.toString().replace (/}\s*$/, 'TESTmyHook(); }');
//    logit ('FT: modal_messages = '+ ft);
    unsafeWindow.TESTmyHook = t.hook;
/***
var scr = document.createElement('script');   
scr.innerHTML = 'modal_messages = '+ ft;
document.body.appendChild(scr);
setTimeout ( function (){document.body.removeChild(scr);}, 500);
***/
//with (unsafeWindow){
//  eval ('unsafeWindow.modal_messages = '+ ft);
//  eval ('modal_messages = function (){alert("xxx")}');
logit ("WITH");
  unsafeWindow.modal_messages = eval ('function (){alert("xxx")}');
logit ("EVALED");
//}
setTimeout ( function(){
  var ft=unsafeWindow.modal_messages.toString();
  logit('unsafeWindow.modal_messages:\n'+ ft.substr(ft.length-500));
}, 100);
  },
  
  hook : function (){
    logit ('TestSomething.hook');
    logit ('tvuid: '+ tvuid);    
    logit ('unsafeWindow.tvuid: '+ unsafeWindow.tvuid);    
  },
  
}




var battleReports = {
  init : function (){
    var t = battleReports;
    t.getReportDisplayFunc = new CalterUwFunc ('getReportDisplay', [['return s.join("")', 'var themsg=s.join(""); themsg=getReportDisplay_hook(themsg, arguments[1]); return themsg']]);
    unsafeWindow.getReportDisplay_hook = t.hook;
    t.getReportDisplayFunc.setEnable (true);
    t.renderBattleReportFunc = new CalterUwFunc ('MarchReport.prototype.renderBattleReport', [['return k.join("")', 'var themsg=k.join(""); themsg=renderBattleReport_hook(themsg, this.rslt); return themsg']]);
    unsafeWindow.renderBattleReport_hook = t.hook2;
    t.renderBattleReportFunc.setEnable (true);
    t.renderButtonsFunc = new CalterUwFunc ('MarchReport.prototype.generateBackButton', [[/return \"(.*)\"/i, 'var msg="$1"; return battleReports_hook3(msg, this.rptid);']]);
    unsafeWindow.battleReports_hook3 = t.generateBackButtonHook;
    t.renderButtonsFunc.setEnable (true);
    unsafeWindow.deleteAreport = t.e_deleteReport;
//setTimeout (function(){logit('MarchReport.prototype.generateBackButton:\n'+ unsafeWindow.MarchReport.prototype.generateBackButton.toString(), 3, 1)}, 100);
  },

  isRoundsAvailable : function (){
    var t = battleReports;
    return t.getReportDisplayFunc.isAvailable();
  },
  isDeleteAvailable : function (){
    var t = battleReports;
    return t.renderButtonsFunc.isAvailable();
  },
  
    
  generateBackButtonHook : function (msg, rptid){
    if (!Options.reportDeleteButton)
      return msg;
    var delBut = msg.replace ('onclick=\'', 'onclick=\'deleteAreport('+ rptid +',false); ');
    delBut = delBut.replace (/<span>(.*)<\/span>/, '<span>'+ unsafeWindow.g_js_strings.commonstr.deletetx +'</span>');
//logit ('DELBUT: '+ delBut);    
    return msg + delBut;
  },  

  e_deleteReport : function (rptid){
    var t = battleReports;
    t.ajaxDeleteMyReport (rptid);
  },
    
  ajaxDeleteMyReport : function (rptid, isUnread, side, isCityReport, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.s0rids = rptid;
    params.s1rids = '';
    params.cityrids = '';
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/deleteCheckedReports.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok && isUnread){
          unsafeWindow.seed.newReportCount = parseInt(seed.newReportCount) - 1;
          unsafeWindow.messages_notify_bug()
        }    
        if (notify)
          notify (rslt.errorMsg);
      },
      onFailure: function () {
        if (notify)
          notify ('AJAX ERROR');
      },
    });
  },
  
  hook2 : function (msg, rslt){
    if (rslt.rnds && Options.dispBattleRounds){
      msg = msg.replace (/(Attackers.*?<span.*?)<\/div>/im, '$1<BR>Rounds: '+ rslt.rnds +'</div>');
    }
    return msg;
  },
  hook : function (msg, rslt){
    if (rslt.rnds && Options.dispBattleRounds){
      msg = msg.replace (/(Attackers <span.*?)<\/div>/im, '$1<BR>Rounds: '+ rslt.rnds +'</div>');
    }
    return msg;
  },
}


var anticd = {
  isInited : false,
  KOCversion : '?',
  
  init: function (){
    if (this.isInited)
      return this.KOCversion;
    unsafeWindow.cm.cheatDetector.detect = eval ('function (){}');
    var scripts = document.getElementsByTagName('script');
    for (var i=0; i<scripts.length; i++){
      if (scripts[i].src.indexOf('camelotmain') >=0){
        break;
      }
    }
    if (i<scripts.length){
      var m = scripts[i].src.match (/camelotmain-(.*).js/);  
      if (m)
        this.KOCversion = m[1];
    }
    this.isInited = true;
    // more coming soon :)
  },
  
  getKOCversion : function (){
    return this.KOCversion;
  },
}
anticd.init ();



/***
<img src='http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/avatars/25/m16.jpg'/>
<div class='content'>
  <div class='info'>
    <a  class='nm' onclick='Chat.viewProfile(this,9640194,false);return false;'>Lord Sasuke_of_leaf</a>
    <span class='time'>17:17</span>
  </div>
  <div class='clearfix'>
    <div class='tx'>
      if ur really bored try it
    </div>
  </div>
</div>


<img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/avatars/25/f9.jpg">
<div class="content">
  <div class="info">
    <a class="nm" onclick="Chat.viewProfile(this,3813948,false);return false;">Lady Aerwyn</a>
    <b style="color: rgb(165, 102, 49); font-size: 9px;"> says to the alliance:</b>
    <span class="time">17:32</span>
  </div>
  <div class="clearfix">
    <div class="tx">
      ok, heading out to dinner with family... be back laters
    </div>
  </div>
</div>


WHISPER (chatDivContentHook) .....

<img src='http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/avatars/25/m1.jpg'/>
<div class='content'>
  <div class='info'>
    <a  class='nm' onclick='Chat.viewProfile(this,2282354,false);return false;'>Lord Jetson</a>
    <b style='color:#A56631;font-size:9px;'> whispers to you:</b>
    <span class='time'>17:46</span>
  </div>
  <div class='clearfix'>
    <div class='tx'>
      test
    </div>
  </div>
</div>


<div class="chatwrap clearfix direct">
  <img src="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/avatars/25/m1.jpg">
  <div class="content">
    <div class="info">
      <span class="nm">Lord Jetson</span>
      <b style="color: rgb(165, 102, 49); font-size: 9px;"> whispers to <a onclick="Chat.viewProfile(this,2282354); return false;" class="nm">jetson</a>:</b>
      <span class="time">20:47</span>
    </div>
    <div class="clearfix">
      <div class="tx">
        test
      </div>
    </div>
  </div>
</div>
****/
  
var ChatStuff = {
  chatDivContentFunc : null,
  getChatFunc : null,
  
  init : function (){
    var t = ChatStuff;
    t.chatDivContentFunc = new CalterUwFunc ('Chat.chatDivContent', [['return e.join("");', 'var msg = e.join("");\n msg=chatDivContent_hook(msg);\n return msg;']]);
    unsafeWindow.chatDivContent_hook = t.chatDivContentHook;
    unsafeWindow.ptChatIconClicked = t.e_iconClicked;
    t.setEnable (Options.chatEnhance);
  },
  
  isAvailable : function (){
    var t = ChatStuff;
    t.chatDivContentFunc.isAvailable ();
  },
  
  setEnable : function (tf){
    var t = ChatStuff;
    t.chatDivContentFunc.setEnable (tf);
  },
  
  e_iconClicked : function (name){
    var e = document.getElementById('mod_comm_input');
    e.value = '@'+ name +' ';
  },

  
// "Report No: 5867445"  --->  see unsafeWindow.modal_alliance_report_view()
      
  chatDivContentHook : function (msg){
    var t = ChatStuff;
    var class = '';
    var m = /div class='info'>.*<\/div>/im.exec(msg);
    if (m == null)
      return msg;
    if (m[0].indexOf('flüstert') >= 0) {
   if (Options.chatwhisper)
      class = 'ptChatWhisper';
   else class = '';
    }
    else if (m[0].indexOf('sagt zur Allianz') >= 0){
   if (Options.chatbold)
      class = 'ptChatAlliance';
   else class = '';
        }
    else {
   class = '';
   if (Options.chatbold)
      class = 'ptChatGlobalBold';
   if (Options.chatglobal)
       class = 'ptChatGlobal';
   if (Options.chatbold && Options.chatglobal)
      class = 'ptChatGlobalAll';
        }


    msg = msg.replace ("class='content'", "class='content "+ class +"'");
    
    
    if (msg.indexOf('claimAllianceChat')<0){
      msg = msg.replace (/([0-9]{1,3})\s*(,|-)\s*([0-9]{1,3})/img, '<A onclick=\"ptGotoMap($1,$3)\">$1$2$3</a>');
    }
      
    var m = /(Lord|Lady) (.*?)</im.exec(msg);
    if (m != null)
      msg = msg.replace (/<img (.*?>)/img, '<A onclick=\"ptChatIconClicked(\''+ m[2] +'\')\"><img class=\"ptChatIcon\" $1</a>');
    return msg;
  },
}
// useless :( ......
/***/

/***
RSLT:
  (string) s0Kid = 57526
  (string) s1Kid = 35216
  (string) s1KLv = 1
  (number) s0KCombatLv = 0
  (string) s1KCombatLv = Higher
  (object) fght = [object Object]
    (object) s1 = [object Object]
      (array) u2 = 89000,89000
        (string) 0 = 89000
        (number) 1 = 89000

      (array) u9 = 1000,1000
        (string) 0 = 1000
        (number) 1 = 1000


  (number) rnds = 3
  (number) winner = 1
  (number) wall = 100
  (number) s0atkBoost = 0
  (number) s0defBoost = 0
  (number) s1atkBoost = 0
  (number) s1defBoost = 0.2
  (boolean) conquered = false
  (array) loot = 111139,763000,643000,78000,138000
    (number) 0 = 111139
    (number) 1 = 763000
    (number) 2 = 643000
    (number) 3 = 78000
    (number) 4 = 138000

  (string) errorMsg = Something has gone wrong! Please try again, or refresh if this message reappear
***/
/***/
function displayReport (rptid, side){
  var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
  params.rid = rptid;
  params.side = side;
  
  new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchReport.php" + unsafeWindow.g_ajaxsuffix, {
    method: "post",
    parameters: params,
    onSuccess: function (rslt) {
logit (inspect (rslt, 5, 1));      
      if (notify)
        notify (rslt.errorMsg);
    },
    onFailure: function () {
      if (notify)
        notify ('AJAX ERROR');
    },
  });
}
/***/
/*************** WILDS TAB *********************/

var wildNames = {
   0: 'Moor',
  10: 'Grassland',
  11: 'See',
  20: 'Wälder',
  30: 'Hügel',
  40: 'Berg',
  50: 'Ebene',
};

var mercNames = {
  0: 'Niemand',
  1: 'Novizen',
  2: 'Fortgeschrittener Anfänger',
  3: 'Veteranen',
};

Tabs.Wilds = {
  tabLabel : 'Wildnisse',
  tabOrder : 35,

  cont : null,
//  state : null,
  upGoldTimer : null,
  wildList : [],
  buildList : {},
  
  init : function (div){
    var t = Tabs.Wilds;
    t.cont = div;
    unsafeWindow.ptButMaxTraps = t.e_butMaxTraps;
    unsafeWindow.ptInpWildTraps = t.e_inpTraps;
    unsafeWindow.ptButWildSet = t.e_butWildSet;
    t.cont.innerHTML = '<DIV id=wildContent style="maxheight:665px; height:665px; overflow-y:auto">';
//    t.show ();
  },

  hide : function (){
    var t = Tabs.Wilds;
    clearTimeout (t.upGoldTimer);
  },
  
  show : function (){
    var t = Tabs.Wilds;
    clearTimeout (t.upGoldTimer);
    
    m = '<CENTER>'+ strButton20('Zurücksetzten', 'id=ptwref') +'</center><TABLE cellspacing=0 cellpadding=0 class=ptTabPad align=center>';
    for (var c=0; c<Cities.numCities; c++){
      var city = Cities.cities[c];
      var cWilds = Seed.wilderness['city'+city.id];
      t.wildList[c] = [];
      var castle = parseInt(Seed.buildings['city'+ city.id].pos0[1]);
      var totw = 0;
      if (matTypeof(cWilds)=='object'){
        for (var k in cWilds)
          ++totw;
      }       
      m += '<TR><TD colspan=20><DIV class=ptstat><TABLE class=ptNoPad width=100%><TR><TD width=100></td><TD width=90% align=center>'+ city.name
        +' &nbsp; ('+ city.x +','+ city.y +')</td><TD width=100 align=right>Wildnisse: '+ totw +' von '+ castle +' &nbsp; </TD></tr></table></div></td></tr>';
      var row = 0;  
      var sortem = [];

      if (matTypeof(cWilds) != 'array') {
        m += '<TR style="background-color:white; font-weight:bold;" align=right><TD align=left>Wildniss</td><TD></td><TD align=left>Koordinate</td><TD>Fallen</td><TD align=left>Söldner</td>\
         <TD width=15></td><TD colspan=3 class=entry>'+ htmlTitleLine(' VERTEIDIGUNG ') +'</td></tr>';
        for (var k in Seed.wilderness['city'+city.id])
          sortem.push (Seed.wilderness['city'+city.id][k]);
        sortem.sort (function (a,b){
          var x; if ((x = b.tileLevel-a.tileLevel)!=0)
            return x;
          return a.tileType-b.tileType;
        });
        for (i=0; i<sortem.length; i++){
          var wild = sortem[i];
          var wildDef = Seed.wildDef['t'+wild.tileId];
          if (wildDef==undefined || !wildDef)
            wildDef = {fort60Count:0, mercLevel:0};
          var maxTraps = parseInt(wild.tileLevel)*100;
          var maxBuild = maxTraps - parseInt(wildDef.fort60Count);
          t.wildList[c][i] = [wild.tileId, maxBuild];          
          m += '<TR align=right'+ (row++%2?'':' class=ptOddrow') +'><TD align=left>'+ wildNames[wild.tileType] +'</td>\
            <TD>'+ wild.tileLevel +'</td><TD align=center><A onclick="ptGotoMap('+ wild.xCoord +','+ wild.yCoord +')">'+ wild.xCoord +','+ wild.yCoord +'</a></td>\
            <TD align=right><B>'+ wildDef.fort60Count +'</b></td><TD align=center><B>'+ mercNames[wildDef.mercLevel] +'</b></td>\
            <TD></td><TD align=left class=ptentry><B>Fallen:</b> <INPUT onchange="ptInpWildTraps(this)" id=ptwt_'+ c +'_'+ i
              + (maxBuild==0?' DISABLED ':'')+' style="margin:0px; padding:0px" type=text size=3 maxlength=4></td>'
          if (wildDef.fort60Count < maxTraps)
            m += '<TD class=ptentry style="padding:0px">'+ strButton14('Max', 'id=ptwx_'+ c +'_'+ i +' onclick="ptButMaxTraps(this)"') +'</td>';
          else
            m += '<TD class=ptentry></td>';
          m += '<TD class=ptentry> &nbsp; &nbsp; <B>Söldner:</b> ' + htmlSelector(mercNames, wildDef.mercLevel, 'id=ptwm_'+ c +'_'+ i) +' &nbsp; &nbsp; </td></tr>';
        }
        m += '<TR><TD colspan=6></td><TD class=ptentry align=center colspan=3><TABLE><TR><TD width=40% align=left>Kosten: <SPAN id=ptwgc_'+ c +'>0</span></td>\
            <TD width=10%>'+ strButton20("Verteidigung Einstellen", 'onclick="ptButWildSet('+ c +')"') +'<TD width=40% align=right>Gold: <SPAN id=ptwgt_'+ c +'>0</span></td></td></tr></table></td></tr>';
      } else {
        m+= '<TR><TD colspan=9> &nbsp; </td></tr>';
      }         
    }
    document.getElementById('wildContent').innerHTML = m + '</table></div>';
    document.getElementById('ptwref').addEventListener ('click', t.show, false);
    t.updateGold ();
  },
    
  e_butWildSet : function (c){
    var t = Tabs.Wilds;
    var totTraps = 0;  
    var cid = Cities.cities[c].id;
    t.buildList = {cityId:cid, list:[]};
          
    for (var w=0; w<t.wildList[c].length; w++){
      var wild = Seed.wilderness['city'+cid]['t'+t.wildList[c][w][0]];
      var wildDef = Seed.wildDef['t'+t.wildList[c][w][0]];
// TODO: Seed.wildDef is null if just aquired
if (wildDef==undefined || !wildDef)
  wildDef = {fort60Count:0, mercLevel:0};
    
      var numTraps = parseInt(document.getElementById('ptwt_'+ c +'_'+ w).value, 10);
      if (isNaN(numTraps))
        numTraps = 0;
      totTraps += numTraps;
      if (numTraps > 0)
        t.buildList.list.push (['T', wild.tileId, numTraps]);
      var mercId =document.getElementById('ptwm_'+ c +'_'+ w).value;
      if (wildDef.mercLevel != mercId)
        t.buildList.list.push (['M', wild.tileId, mercId, wildDef.mercLevel]);
    }

    var totCost = totTraps * 200;
    if (totCost > parseInt(Seed.citystats['city'+cid].gold[0])){
      document.getElementById('ptwgc_'+ c).innerHTML = '<SPAN class=boldRed>'+ addCommasInt(totCost) +'</span>';
      return;
    }
    if (t.buildList.list.length == 0)
      return;
    t.setCurtain (true);
    var popDiv = t.setPopup (true);
    popDiv.innerHTML = '<TABLE class=ptTab width=100% height=100%><TR><TD>\
          <DIV class=ptstat>Setzte Wildniss Verteidigung...</div>\
          <DIV id=ptWildBuildDiv class=ptDiv style="padding:10px; height:225px; max-height:225px; overflow-y:auto"></div>\
          </td></tr><TR><TD align=center>'+ strButton20('Abbrechen', 'id=ptWildCancel') +'</td></tr></table>';
    document.getElementById('ptWildCancel').addEventListener('click', t.e_buildCancel, false);
    t.processQue(null);  
  },
  
  e_buildCancel : function (){
    var t = Tabs.Wilds;
    t.setCurtain(false);
    t.setPopup(false);
    t.show();
  },
  
  processQue : function (errMsg){
    var t = Tabs.Wilds;
    var what = t.buildList.list.shift();
    var div = document.getElementById('ptWildBuildDiv');
    if (what==null || errMsg){
      if (errMsg)
        div.innerHTML += '<BR><SPAN style="white-space:normal;" class=boldRed>ERROR: '+ errMsg +'</span>';
      else
        div.innerHTML += '- Fertig!<BR>';
      document.getElementById('ptWildCancel').firstChild.innerHTML = 'Schließen';
      return;
    }
    if (div.innerHTML != '')
      div.innerHTML += '- Fertig!<BR>';
    var wild = Seed.wilderness['city'+ t.buildList.cityId]['t'+what[1]];
    if (what[0] == 'T'){
      div.innerHTML += 'Baue '+ what[2] +' fallen für '+ Cities.byID[t.buildList.cityId].name +'\'s Wildniss auf '+ wild.xCoord +','+ wild.yCoord +' ... ';
      t.postBuyTraps (t.buildList.cityId, what[1], what[2], t.processQue);
    } else {
      div.innerHTML += 'Beauftrage '+ mercNames[what[2]] +' für '+ Cities.byID[t.buildList.cityId].name +'\'s Wildniss verteidigung auf '+ wild.xCoord +','+ wild.yCoord +' ';
      t.postHireMercs (t.buildList.cityId, what[1], what[2], what[3], t.processQue);
    }
  },
  
  setPopup : function (onoff){
    var t = Tabs.Wilds;
    if (onoff){
      var div = document.createElement('div');
      div.id = 'ptWildPop';
      div.style.backgroundColor = '#fff';
      div.style.zindex = mainPop.div.zIndex+2;
      div.style.opacity = '1';
      div.style.border = '3px outset red';
      div.style.width = '550px';
      div.style.height = '300px';
      div.style.display = 'block';


      div.style.position = 'absolute';
      div.style.top = '100px';
      div.style.left = '100px';
      t.cont.appendChild (div);
      return div;
    } else {
      t.cont.removeChild (document.getElementById('ptWildPop'));
    }
  },

  setCurtain : function (onoff){
    var t = Tabs.Wilds;
    if (onoff){
      var off = getAbsoluteOffsets (t.cont);
      var curtain = document.createElement('div');
      curtain.id = 'ptWildCurtain';
      curtain.style.zindex = mainPop.div.zIndex+1;
      curtain.style.backgroundColor = "#000000";
      curtain.style.opacity = '0.5';
      curtain.style.width = t.cont.clientWidth +'px';
      curtain.style.height = t.cont.clientHeight +'px';
      curtain.style.display = 'block';
      curtain.style.position = 'absolute';
      curtain.style.top = off.top + 'px';
      curtain.style.left = off.left + 'px';
      t.cont.appendChild (curtain);
    } else {
      t.cont.removeChild (document.getElementById('ptWildCurtain'));
    }
  },
  
  e_butMaxTraps : function (e){
    var t = Tabs.Wilds;
    var c = e.id.substr(5,1);
    var w = e.id.substr(7);
    var inp = document.getElementById('ptwt_'+ c +'_'+ w);
    inp.value = t.wildList[c][w][1];
    t.e_inpTraps (inp);
  },
  
  e_inpTraps : function (e){
    var t = Tabs.Wilds;
    var c = e.id.substr(5,1);
    var w = e.id.substr (7);
    var tot = 0;
    for (var i=0; i<t.wildList[c].length; i++) {
      var val = parseInt(document.getElementById('ptwt_'+ c +'_'+ i).value, 10);
      if (isNaN(val))
        val = 0;
      tot += val;
    }  
    document.getElementById('ptwgc_'+ c).innerHTML = addCommasInt(tot * 200);
    if (isNaN(e.value) || e.value<0 || e.value>t.wildList[c][w][1]){
      e.value = '';
      e.style.backgroundColor = '#ffaaaa';
    } else
      e.style.backgroundColor = null;
  },

  updateGold : function (){
    var t = Tabs.Wilds;
    for (var c=0; c<Cities.numCities; c++){
      var e = document.getElementById('ptwgt_'+ c +'');
      if (e)
        e.innerHTML = addCommasInt(Seed.citystats['city'+Cities.cities[c].id].gold[0]);
    }
    t.upGoldTimer = setTimeout (t.updateGold, 2000);
  },
  
  postBuyTraps : function (cid, tid, quant, notify){
    if (DISABLE_POST_DEFENSES){
      setTimeout (function (){notify(null)}, 1500);
      return;
    }
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.cid = cid;
    params.tid = tid;
    params.quant = quant;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/buyWildTraps.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok){
          if (!Seed.wildDef["t"+ tid])
            Seed.wildDef["t"+ tid] = {tileId:tid, fort60Count:0, mercLevel:0};
          Seed.wildDef["t"+ tid].fort60Count = parseInt(Seed.wildDef["t"+ tid].fort60Count) + parseInt(quant);
        }  
        if (notify)
          notify (rslt.errorMsg);
      },
      onFailure: function () {
        if (notify)
          notify ('AJAX ERROR');
      },
    });
  },

  postHireMercs : function (cid, tid, newLevel, oldLevel, notify){
    if (DISABLE_POST_DEFENSES){
      setTimeout (function (){notify('OK, so it\'s not really an error, it\'s just George playing around to see how the error message looks. It\'s a long one, how does it fit? Is it OK? Are you sure? JANE! Get me off of this thing!')}, 1500);
      return;
    }
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.cid = cid;
    params.tid = tid;
    params.lv = newLevel;
    params.olv = oldLevel;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/hireWildMerc.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok){
          if (!Seed.wildDef["t"+ tid])
            Seed.wildDef["t"+ tid] = {tileId:tid, fort60Count:0, mercLevel:0};
          Seed.wildDef["t"+ tid].mercLevel = newLevel;
        }
        if (notify)
          notify (rslt.errorMsg);
      },
      onFailure: function () {
        if (notify)
          notify ('AJAX ERROR');
      },
    });
  },
          
}    
   
/*************** RITTER TAB *********************/
Tabs.Ritter = {
  tabLabel : 'Ritter',
  tabOrder : 30,
  cont : null,
  displayTimer : null,

  init : function (div){
    var t = Tabs.Ritter;
    t.cont = div;
    unsafeWindow.ptAssignSkill = t.clickedAssignPoints;
    t.cont.innerHTML = '<STYLE>table.ptTabPad tr.ptwpad {background-color:#ffffff; padding-left:15px}</style>\
       <DIV id=ptknightdiv style="max-height:660px; height:660px; overflow-y:auto">';
  },

  hide : function (){
    var t = Tabs.Ritter;
    clearTimeout (t.displayTimer);
  },

  show : function (){
    var t = Tabs.Ritter;
    clearTimeout (t.displayTimer);
    
    function _dispKnight (roleId, knight){
      var rid = roleId;
      if (roleId==null)
        rid = 1;
      var sty='';  
      if (row++ % 2)
        sty = 'class=ptOddrow ';        
      m = '<TR '+ sty +'valign=top align=right><TD><B>'+ (roleId==null ? '':knightRoles[rid][0]) +'</b></td><TD align=left>';
      if (knight == null) {
        m += 'Niemand Eingestellt</td><TD colspan=4></td><TD class=ptentry colspan=5></td><TD colspan=2></td></tr>';
      } else {
        var level = parseInt(Math.sqrt(parseInt(knight.experience) / 75)) + 1;
        var unpoints = level - parseInt(knight.skillPointsApplied);
        var salary = (parseInt(knight.skillPointsApplied) + 1) * 20;
        totSalary += salary;
        var ass = '';
        if (knight.knightStatus == 10){
          ass = '<TD class=ptentry align=left colspan=4>Maschieren</td>';
        } else {  
          if (unpoints > 0){
            unpoints = '<SPAN class="boldRed">'+ unpoints +'</span>';
          for (var i=0; i<4; i++){
            var sty = 'padding-left:1px;';
            if (i == rid)   // bold it
              sty += 'font-weight:bold;color:#116654';
            ass += '<TD class=ptentry align=left style="'+ sty +'" ><A style="'+ sty +'" onclick="ptAssignSkill(this,' + cid +','+ knight.knightId +','+ i +')">['+ knightRoles[i][2] +'] &nbsp;</a></td>';
          }
          }
          else
            ass = '<TD class=ptentry colspan=4></td>';
        }  
        var skills = [];
        for (var i=0; i<4; i++){
          if (i == rid)
            skills[i] = '<B>'+ knight[knightRoles[i][1]] +'</b>';
          else
            skills[i] = knight[knightRoles[i][1]];
        }          
        m += knight.knightName + '</td><TD>'+ skills[0] +'</td><TD>'+ skills[1] +'</td><TD>'+ skills[2] +'</td><TD>' + skills[3]
          +'</td><TD class=ptentry>'+ unpoints +'</td>'+ ass +'<TD>'+ addCommas(salary)
          +'</td><TD>'+ level +'</td></tr>';
      }
      return m;
    }          
    
    var totSalary = 0;
    var m = '<TABLE cellspacing=0 align=center class=ptTabPad><TBODY>';
    for (var c=0; c<Cities.numCities; c++) {
      var cid = Cities.cities[c].id;
      m += '<TR><TD colspan=13><DIV class=ptstat>'+ Cities.cities[c].name +'</div></td></tr>\
          <TR class=ptwpad style="font-weight:bold" align=right><TD width=70>Rolle</td><TD width=160 align=center>Name</td><TD width=26>Politik</td><TD width=26>Schlacht</td>\
          <TD width=26>Int.</td><TD width=26>Ressis</td><TD width=90 align=center colspan=5>-= Ritter Punkte =-</td><TD width=40 align=right> Kosten </td><TD width=35>Level</td></tr>';
      totSalary = 0;
      var did = {};
      var row = 0;
      for (var i=0; i<knightRoles.length; i++){
        var leader = Seed.leaders['city'+cid][knightRoles[i][1]+'KnightId'];
        if (leader == 0)
          m += _dispKnight (i, null);
        else {
          m += _dispKnight (i, Seed.knights['city'+cid]['knt'+leader]);
          did['knt'+leader] = true;
        }
      }
      var list = [];
      for (k in Seed.knights['city'+cid]){
        if (!did[k])
          list.push (Seed.knights['city'+cid][k]);
      }
      list.sort (function (a,b){return parseInt(b.combat)-parseInt(a.combat)});
      for (i=0; i<list.length; i++)
        m += _dispKnight (null, list[i]);
      m += '<TR align=right><TD colspan=11><B>Gesamt Kosten:</b></td><TD>'+ addCommas(totSalary) +'</td></tr>';        
    }
    document.getElementById('ptknightdiv').innerHTML = m +'</tbody></table></div>';
    t.displayTimer = setTimeout (t.show, 10000);
  },


  clickedAssignPoints : function (e, cid, kid, rid){
    var t = Tabs.Ritter;
    clearTimeout (t.displayTimer);
      
    var knight = Seed.knights['city'+cid]['knt'+kid];
    if (knight.knightStatus == 10){
      var row = e.parentNode.parentNode;
      row.childNodes[7].innerHTML = 'Maschieren';
      return;
    }
    sk = [];
    var unassigned = parseInt(Math.sqrt(parseInt(knight.experience)/75)) + 1  - parseInt(knight.skillPointsApplied);        
    for (var i=0; i<4; i++){
      sk[i] = parseInt(knight[knightRoles[i][1]]);
      if (i == rid)
        sk[i] += unassigned;
    }
    var row = e.parentNode.parentNode;
    for (i=row.cells.length-1; i>=1; i--)
      row.deleteCell (i);
    var newCell=row.insertCell(-1);
    newCell.colSpan = 12;
    newCell.align= 'left';
    newCell.style.padding='1px 5px 1px 10px';
    var div = document.createElement ('div');
    div.style.backgroundColor = '#ffffff';
    div.style.textAlign = 'center';
    div.style.border = '1px solid';
    div.style.width = '98%';
    div.style.whiteSpace = 'normal';
    newCell.appendChild (div);
    div.innerHTML = ' '+ unassigned +' skill punkte(e) auf '+ knightRoles[rid][1] +' verteilt... ';
    t.postSkillPoints (cid, kid, sk[0], sk[1], sk[2], sk[3], function (r){t.postDone(r, div)});  
  },
  
  postDone : function (rslt, div){
    var t = Tabs.Ritter;
    clearTimeout (t.displayTimer);
    if (rslt.ok){
      div.innerHTML += '<B>Fertig.</b>';
      t.displayTimer = setTimeout (t.show, 5000);
    } else {
      div.innerHTML += '<BR><SPAN class=boldRed>ERROR: '+ rslt.errorMsg +'</span>';
      t.displayTimer = setTimeout (t.show, 10000);
    }
  },
  
  postSkillPoints : function (cid, kid, pol, com, int, res, notify){  
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.cid = cid;
    params.kid = kid;
    params.p = pol;
    params.c = com;
    params.i = int;
    params.r = res;
    if (DISABLE_POST_KNIGHT_SKILLS){   
      setTimeout (function (){notify({ok:true})}, 1500);    
//      setTimeout (  function (){notify({ok:false, errorMsg:"FAKE ERROR message, a long one, to test how it will fit and overflow! Perhaps you'll need to retry?"})}  , 2000);    

      return;  
    }
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/skillupKnight.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok) {
          var knight = Seed.knights["city" + cid]["knt" + kid];
          var up = pol + com + int + res - knight.politics - knight.combat - knight.intelligence - knight.resourcefulness;
          knight.politics = pol;
          knight.combat = com;
          knight.intelligence = int;
          knight.resourcefulness = res;
          knight.skillPointsApplied = (parseInt(knight.skillPointsApplied) + up).toString();
        }
        if (notify)
          notify (rslt);
      },
      onFailure: function () {
        if (notify)
          notify (rslt);
      },
    });
  },
};
/**************/

var messageNav = {
  mmFunc : null,
  mmsFunc : null,
  
  init : function (){
    t = messageNav;
    t.mmFunc = new CalterUwFunc ('modal_messages', [[/}\s*$/, 'setTimeout(messageNav_hook,0); }']]);
    t.mmsFunc = new CalterUwFunc ('modal_messages_send', [[/{\s*var params/i, '{\nif (modal_messages_send_hook()) return;\nvar params']]);
    unsafeWindow.messageNav_hook = messageNav.hook;
    unsafeWindow.modal_messages_send_hook = messageNav.msgSendHook;
    t.mmFunc.setEnable (true);
    t.mmsFunc.setEnable (true);
  },

  setEnable : function (tf){
  },

  isAvailable : function (){
    t = messageNav;
    return t.mmFunc.isAvailable();
  },
  
  hook : function (){
    if (!Options.enhanceMsging)
      return;
    var div = document.getElementById('modal_msg_view_actions');
    var but = makeButton20('Weiterleiten');
    div.appendChild (but);
    but.addEventListener ('click', messageNav.eventForward, false);
    div = document.getElementById('modal_msg_write_to').parentNode;
    div.innerHTML = '<TABLE><TR><TD class=xtab><b>An:</b> <INPUT type=text id=modal_msg_write_to></td><TD class=xtab><SPAN id=ptfwdbut></span></td></tr></table>';
    var button = makeButton20('Alle Offiziere');
    document.getElementById('ptfwdbut').appendChild (button);
    button.addEventListener ('click', function (){document.getElementById("modal_msg_write_to").value = "<officers>"}, false);
  },

  eventForward : function (){
    document.getElementById('modal_msg_write_subj').value = "WEITERLEITUNG: " + document.getElementById('modal_msg_view_subj').innerHTML.toString().stripTags();
    document.getElementById('modal_msg_write_to').value = '';
    var from = document.getElementById('modal_msg_view_from').children[0].innerHTML;
    var body = document.getElementById('modal_msg_view_body').innerHTML.replace(/\n/g, '').replace(/<br>/gi, '\n').stripTags().replace (/back$/i, '');
    document.getElementById('modal_msg_write_txt').value = '[Original Nachricht von '+ from +' :]\n'+ body;
    unsafeWindow.modal_messages_compose();
  },

  msgSendHook : function (){
    if (!Options.enhanceMsging)
      return;
    var to = document.getElementById("modal_msg_write_to").value.trim();
    if (to.toLowerCase() != '<officers>' || getMyAlliance()[0]==0)
      return false;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.toIds = getMyAlliance()[0];
    params.subject = document.getElementById("modal_msg_write_subj").value +' [Leader Mail]';
    params.message = document.getElementById("modal_msg_write_txt").value;
    params.type = 'alliance';
    new AjaxRequest(unsafeWindow.g_ajaxpath + "ajax/sendMessage.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        onSuccess: function (message) {
            var rslt = eval("(" + message.responseText + ")");
            if (rslt.ok) {
                unsafeWindow.Modal.showAlert(unsafeWindow.g_js_strings.modal_messages_send.msgsent);
                document.getElementById('modal_msg_write_to').value = "";
                document.getElementById('modal_msg_write_subj').value = "";
                document.getElementById('modal_msg_write_txt').value = ""
            } else {
                unsafeWindow.Modal.showAlert(unsafeWindow.g_js_strings.modal_messages_send.enterexistingname)
            }
        },
        onFailure: function () {
          unsafeWindow.Modal.showAlert(unsafeWindow.g_js_strings.modal_messages_send.oopscompose)
        },
    });
    return true;
  },
}


var AttackDialog = {
  init : function (){
    var t = AttackDialog;
    t.modal_attackFunc = new CalterUwFunc ('modal_attack', [[/}\s*$/, 'attackDialog_hook(); }']]);
    unsafeWindow.attackDialog_hook = t.modalAttackHook;
    t.modal_attackFunc.setEnable (true);
  },
  
  setEnable : function (){
  },

  isKnightSelectAvailable : function (){
    var t = AttackDialog;
    return t.modal_attackFunc.isAvailable();
  },
  isAttackCityPickerAvailable : function (){
    var t = AttackDialog;
    return t.modal_attackFunc.isAvailable();
  },
    
  modalAttackHook : function (){
    var t = AttackDialog;
    if (Options.fixKnightSelect || Options.attackCityPicker){
      for (var i=1; i<6; i++)
        document.getElementById('modal_attack_tab_'+ i).addEventListener('click', t.e_changeMarchType, false);
    }
    if (Options.attackCityPicker){
      setTimeout (t.initCityPicker, 0);
    }      
  },
  
  initCityPicker : function (){
    var t = AttackDialog;
    var div = document.getElementById('modal_attack_target_numflag'); // as of KofC version 96;
    var mySpan;
    if (div) {
      div.parentNode.innerHTML += ' &nbsp; <SPAN id=modal_attack_citybuts></span>';
    } else {
      var span = document.getElementById('modal_attack_target_coords');   // KofC version 116+;
      span.parentNode.parentNode.firstChild.innerHTML += ' &nbsp; <SPAN id=modal_attack_citybuts></span>';
    }
    new CdispCityPicker ('ptatp', document.getElementById('modal_attack_citybuts'), false, t.e_CityButton);
    var cityIdx = Cities.byID[unsafeWindow.currentcityid].idx;
    thisCityBut = document.getElementById('ptatp_'+ cityIdx);
    thisCityBut.style.opacity = '0.5';
    thisCityBut.disabled = true;
    if (document.getElementById('modal_attack_tab_4').className=='selected' || document.getElementById('modal_attack_tab_3').className=='selected')   // don't do for attack or scout
      document.getElementById('modal_attack_citybuts').style.display = 'none';
  },
  
  e_CityButton : function (city){
    document.getElementById('modal_attack_target_coords_x').value = city.x;
    document.getElementById('modal_attack_target_coords_y').value = city.y;
    unsafeWindow.modal_attack_update_time();
  },
      
  e_changeMarchType : function (evt){
    var t = AttackDialog;
    var marchType = parseInt(evt.target.id.substr(17));  
    if (Options.attackCityPicker){
      if (marchType==3 || marchType==4)
        document.getElementById('modal_attack_citybuts').style.display = 'none';
      else
        document.getElementById('modal_attack_citybuts').style.display = 'inline';
    }
    if (Options.fixKnightSelect){
      var knightVal = 0;
      var selector = document.getElementById('modal_attack_knight');
      if (selector.length>1 && (marchType==4 || marchType==2))   // if 'attack' or 'reinforce'
        knightVal = 1;
      selector.selectedIndex = knightVal;
    }
  },  
}


var AllianceReports = {
  checkPeriod : 300,
  allianceNames : [],
  saveArfunc : unsafeWindow.allianceReports,

  init : function (){
    t = AllianceReports;
    t.enable (Options.enhanceARpts);
    t.marvFunc = new CalterUwFunc ('modal_alliance_report_view', [['getReportDisplay', 'getReportDisplay_hook2']]);
    unsafeWindow.getReportDisplay_hook2 = t.getReportDisplayHook;
    t.marvFunc.setEnable (true);
  },
   
  getReportDisplayHook : function (a, b){
    var x = '';
    try {
      x = unsafeWindow.getReportDisplay(a,b);  
    } catch (e){
      x = 'Error formatting report: '+ e;
    }
    return x;
  },
  
  enable : function (tf){
    t = AllianceReports;
    if (tf)
      unsafeWindow.allianceReports = t.myAllianceReports;
    else
      unsafeWindow.allianceReports = t.saveArfunc;
  },
  
  myAllianceReports : function (pageNum){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    if (pageNum)
      params.pageNo = pageNum;
    params.group = "a";
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/listReports.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
//logit (inspect (rslt, 1, 1));        
        displayReports (rslt.arReports, rslt.arPlayerNames, rslt.arAllianceNames, rslt.arCityNames, rslt.totalPages);
      },
      onFailure: function (rslt) {
      },
    }, false);

    function displayReports (ar, playerNames, allianceNames, cityNames, totalPages){
      var msg = new Array();
      var myAllianceId = getMyAlliance()[0];
      msg.push ("<STYLE>.msgviewtable tbody .myCol div {margin-left:5px; overflow:hidden; white-space:nowrap; color:#000}\
            .msgviewtable tbody .myFeindlich div {font-weight:600; color:#600}\
            .msgviewtable tbody .myGray div {color:#666}\
            .msgviewtable tbody .myRein div {color:#050}\
            .msgviewtable tbody .myWarn div {font-weight:600; color:#442200}\
            </style>");
      msg.push("<div class='modal_msg_reports'>");
      var rptkeys = unsafeWindow.Object.keys(ar);
      if (matTypeof(ar) != 'array') {
//logit ('displayReports: '+ Options.allowAlterAR);        
        if (Options.allowAlterAR)
          msg.push("<div id='modal_alliance_reports_tablediv' class='modal_msg_list'><table width=675 cellpadding='0' cellspacing='0' class='msgviewtable reportviewtable alliancetable'>");
        else
          msg.push("<div id='modal_alliance_reports_tabledivNKA' class='modal_msg_list'><table width=675 cellpadding='0' cellspacing='0' class='msgviewtable reportviewtable alliancetable'>");
        msg.push("<thead><tr><td width=105>Datum</td><td width=40>Typ</td><td width=150>Angreifer</td><td>Ziel</td><td>Anzeigen</td></tr></thead><tbody>");
        for (var i = 0; i < rptkeys.length; i++) {
          var rpt = ar[rptkeys[i]];
          var colClass = '"myCol"';
          rpt.marchType = parseInt(rpt.marchType);
          rpt.side0AllianceId = parseInt(rpt.side0AllianceId);
          var targetDiplomacy = getDiplomacy (rpt.side0AllianceId);
          if (rpt.marchType == 2){
            colClass = '"myCol myRein"';
          } else if (rpt.side1AllianceId != myAllianceId){
            colClass = '"myCol myFeindlich"';
          } else {
            if (parseInt(rpt.side0TileType) < 50){          // if wild
              if (parseInt(rpt.side0PlayerId) == 0)
                colClass = '"myCol myGray"';
              else
                colClass = '"myCol myWarn"';
            } else if (parseInt(rpt.side0PlayerId) == 0) {   // barb
              colClass = '"myCol myGray"';
            } else {
              if (targetDiplomacy == 'friendly')
                colClass = '"myCol myWarn"';
            }
          }
//logit (inspect (ar, 3, 1));
          msg.push ('<tr valign=top');
          if (i%2 == 0)
            msg.push(" class=stripe");
          msg.push("><TD class="+ colClass +"><div>");
          msg.push(unsafeWindow.formatDateByUnixTime(rpt.reportUnixTime));
          msg.push ('<BR>Rpt #');
          msg.push (rpt.reportId);          
          msg.push("</div></td><TD class="+ colClass  +"><div>");
          if (rpt.marchType == 1)
            msg.push (unsafeWindow.g_js_strings.commonstr.transport);
          else if (rpt.marchType == 3)
            msg.push (unsafeWindow.g_js_strings.commonstr.scout);
          else if (rpt.marchType == 2)
            msg.push ('Reinf');
          else
            msg.push (unsafeWindow.g_js_strings.commonstr.attack);

          // attacker ...
          msg.push ("</div></td><TD class="+ colClass +"><div>");
          if (parseInt(rpt.side1PlayerId) != 0)
            msg.push(escape(playerNames["p" + rpt.side1PlayerId]))
          else
            msg.push ('?Unknown?');
            msg.push (' ');
            msg.push (coordLink(rpt.side1XCoord, rpt.side1YCoord));
            msg.push ('<BR>');
          
          if (rpt.side1AllianceId != myAllianceId){
            msg.push (allianceNames['a'+rpt.side1AllianceId]);
            msg.push (' (');
            msg.push (getDiplomacy(rpt.side1AllianceId));
            msg.push (')');
          } else {
            msg.push ('<BR>');
          }
          msg.push ('</div></td>');

          // target ...
          msg.push ("<TD class="+ colClass  +"><DIV>");
          var type = parseInt(rpt.side0TileType);

          if (type < 50){                              // wild
            msg.push(unsafeWindow.g_mapObject.types[type].toString().capitalize());
            msg.push(" Lvl " + rpt.side0TileLevel)
            if (parseInt(rpt.side0PlayerId) != 0) {   // IF OWNED, show owner ...
              msg.push (' [');
              msg.push (escape(playerNames["p" + rpt.side0PlayerId]));
              msg.push ('] ');
            }
          } else {
            if (parseInt(rpt.side0PlayerId) == 0) {   //  barb
              msg.push(unsafeWindow.g_js_strings.commonstr.barbariancamp);
              msg.push(" Lvl " + rpt.side0TileLevel)
            } else {        // city
              msg.push (escape(playerNames["p" + rpt.side0PlayerId]));
              msg.push (' - ');
              msg.push (cityNames['c'+ rpt.side0CityId]);
            }
          }
          msg.push (' ');
          msg.push (coordLink(rpt.side0XCoord, rpt.side0YCoord));
          if (rpt.side0AllianceId!=0 && rpt.side0AllianceId!=myAllianceId){
            msg.push ('<BR>');
            msg.push (allianceNames['a'+rpt.side0AllianceId]);
            msg.push (' (');
            msg.push (targetDiplomacy);
            msg.push (')');
          }

          
/***
        
MY reports, reins works ...
<div><a href="#" onclick="jQuery('#modal_msg_body').trigger('viewReinforcedReport', ['6076798','67674','Elroy','IV','13412958','Duke_Swan','6329','Erisvil',662,477]);return false;">View Report</a></div>

    
OK: <a onclick=" $(&quot;modal_alliance_reports_tabledivNKA&quot;).id=&quot;modal_alliance_reports_tablediv&quot;; modal_alliance_report_view(&quot;6044155&quot;,0,51,9,2282354,&quot;Jetson&quot;,&quot;M&quot;,&quot;Joe7z6bq&quot;,&quot;M&quot;,4,668,437,1299747584,0,643,407);return false;">View</a></div>           
ERROR (Reinf): <a onclick=" $(&quot;modal_alliance_reports_tabledivNKA&quot;).id=&quot;modal_alliance_reports_tablediv&quot;; modal_alliance_report_view(&quot;6043602&quot;,1,51,9,13487684,&quot;Fred8135i&quot;,&quot;M&quot;,&quot;Jetson&quot;,&quot;M&quot;,2,188,696,1299746211,0,23,518);return false;">View</a>
modal_alliance_report_view("6043602",1,51,9,13487684,"Fred8135i","M","Jetson","M",2,188,696,1299746211,0,23,518);return false;'>View</a>                        
modal_alliance_report_view(&quot;6043602&quot;,1,51,9,13487684,&quot;Fred8135i&quot;,&quot;M&quot;,&quot;Jetson&quot;,&quot;M&quot;,2,188,696,1299746211,0,23,518);return false;">View Report</a></div>            
modal_alliance_report_view("6043602",1,51,9,13487684,"Fred8135i","M","Jetson","M",2,188,696,1299746211,0,23,518);return false;">View Report</a></div>            
***/          
          
          
          // 'view report' link ...
          if (Options.allowAlterAR)
            msg.push("</div></td><TD class="+ colClass  +"><div><a onclick=' modal_alliance_report_view(\"");   // ONCLICK ???
          else
            msg.push("</div></td><TD class="+ colClass  +"><div><a onclick=' $(\"modal_alliance_reports_tabledivNKA\").id=\"modal_alliance_reports_tablediv\"; modal_alliance_report_view(\"");   // ONCLICK ???
          msg.push(rpt.reportId);
          msg.push('",');
          if (parseInt(rpt.side1AllianceId) == parseInt(Seed.allianceDiplomacies.allianceId))
            msg.push(1);
          else
            msg.push(0);
          msg.push(",");
          msg.push(rpt.side0TileType);
          msg.push(",");
          msg.push(rpt.side0TileLevel);
          msg.push(",");
          msg.push(rpt.side0PlayerId);
          msg.push(',"');
          if (parseInt(rpt.side0PlayerId) != 0)
            msg.push(escape(playerNames["p" + rpt.side0PlayerId]));
          else
            msg.push(unsafeWindow.g_js_strings.commonstr.enemy);
          msg.push('","');
          if (parseInt(rpt.side0PlayerId) != 0)
            msg.push(escape(playerNames["g" + rpt.side0PlayerId]));
          else
            msg.push(0)
          msg.push('","');
          if (parseInt(rpt.side1PlayerId) > 0)
            msg.push(escape(playerNames["p" + rpt.side1PlayerId]));
          msg.push('","');
          if (parseInt(rpt.side1PlayerId) != 0)
            msg.push(escape(playerNames["g" + rpt.side1PlayerId]));
          msg.push('",');
          msg.push(rpt.marchType);
          msg.push(",");
          msg.push(rpt.side0XCoord);
          msg.push(",");
          msg.push(rpt.side0YCoord);
          msg.push(",");
          msg.push(rpt.reportUnixTime);
          msg.push(",");
          if (parseInt(rpt.reportStatus) == 2)
            msg.push(1);
          else
            msg.push(0);
          if (rpt.side1XCoord) {
            msg.push(",");
            msg.push(rpt.side1XCoord);
            msg.push(",");
            msg.push(rpt.side1YCoord)
          } else {
            msg.push(",,");
          }
          msg.push(");return false;'>Anzeigen</a></div></td></tr>");
        }
        msg.push("</tbody></table></div>");
      }
      msg.push("</div><div id='modal_report_list_pagination'></div>");
      document.getElementById('allianceContent').innerHTML = msg.join("");
      if (pageNum) {
        unsafeWindow.ctrlPagination("modal_report_list_pagination", totalPages, "allianceReports", pageNum)
      } else {
        unsafeWindow.ctrlPagination("modal_report_list_pagination", totalPages, "allianceReports")
      }
    }
  },

}   // end AllianceReports singleton
/************************ Food Alerts *************************/
var FoodAlerts = {

  init : function (){
   var f = FoodAlerts;
   f.e_eachMinute();
  },

  minuteTimer : null,

  e_eachMinute : function (){   
    var f = FoodAlerts;
    var now = unixTime();
    row = [];

    for(i=0; i < Cities.numCities; i++) {
      var rp = getResourceProduction (Cities.cities[i].id);
      var foodleft = parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][0])/3600;
      var usage = rp[1] - parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][3]);
      row[i] = rp[1] - usage;
      var timeLeft = parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][0]) / 3600 / (0-usage) * 3600;
      if (timeLeft<0){
      }
          else if (timeLeft<(Options.foodAlertHours*3600)) {
        var msg = '';
        msg += 'Meine Stadt ' + Cities.cities[i].name.substring(0,10);
        msg += ' (' + Cities.cities[i].x +','+ Cities.cities[i].y + ')';
        msg += ' hat wenig Nahrung! ...habe  '+addCommasWhole(foodleft);
        msg += ' Nahrung... sie reicht noch für ' + timestrShort(timeLeft) + ' - Verbrauch: ' + addCommas(usage);
        sendChat ("/a " + msg);
      }
    }  
  f.minuteTimer = setTimeout (f.e_eachMinute, 600000);
  },  
}

/************************ Tower Alerts ************************/
var TowerAlerts = {
  viewImpendingFunc : null,
  generateIncomingFunc : null,
  fixTargetEnabled : false,
  towerMarches : {},    // track all marches that have been posted to alliance chat
  
  init : function (){
    var t = TowerAlerts;
    var s = GM_getValue ('towerMarches_'+GetServerId());
    if (s != null)
      t.towerMarches = JSON2.parse (s);
 
    t.viewImpendingFunc = new CalterUwFunc ('attack_viewimpending_view', [[/Modal.showModal\((.*)\)/im, 'Modal.showModal\($1\); ptViewImpending_hook(a);']]);
    unsafeWindow.ptViewImpending_hook = t.viewImpending_hook;
    t.viewImpendingFunc.setEnable (true);

    t.generateIncomingFunc = new CalterUwFunc ('attack_generateincoming', [[/.*} else {\s*e = true;\s*}/im, '} else { e = ptGenerateIncoming_hook(); }']]);
    unsafeWindow.ptGenerateIncoming_hook = t.generateIncoming_hook;
  },
    
  // fix 'target', add button  
  viewImpending_hook : function (atkinc){    
    var t = TowerAlerts;  
    var div = document.getElementById('modal_attackimpending_view');
    var isFalse = false;
    if (t.fixTargetEnabled){
      var city = Cities.byID[atkinc.toCityId];
      var target = '';
      if (!city || (atkinc.marchType!=3 && atkinc.marchType!=4)){  
        target = '<B>FAKE BERICHT!</b>';
        isFalse = true;
      } else if (city.tileId == atkinc.toTileId){
        target = city.name + ' ('+ city.x + ','+ city.y +')';
      } else {
        wilds = Seed.wilderness['city'+atkinc.toCityId];
        m = '';
        for (k in wilds){
          if (wilds[k].tileId == atkinc.toTileId){
            m = 'bei '+ wilds[k].xCoord + ','+ wilds[k].yCoord;
            break;
          }
        }
        target = city.name + ', <B>Wildniss '+ m +'</b>';
      }
      div.childNodes[0].innerHTML = '<B>Ziel: </b>'+ target;
    }
    if (!isFalse){
      var d = document.createElement ('div');
      d.innerHTML = '<BR><TABLE><TR><TD><a id=towerPostToChat class=button20><span>Im Allianz Chat Anzeigen!</span></a></td></tr></table>';
      div.appendChild (d);
      document.getElementById('towerPostToChat').addEventListener('click', function (){t.e_buttonPostToChat(atkinc)}, false);
    }
  },

  // fix false reports  
  generateIncoming_hook : function (){    
    return false;
  },
  
  enableFixFalseReports : function (tf){
    var t = TowerAlerts;  
    t.generateIncomingFunc.setEnable (tf);
  },
  enableFixTarget : function (tf){
    var t = TowerAlerts;  
    t.fixTargetEnabled = tf;
  },
  
  isFixTargetAvailable : function (){
    var t = TowerAlerts;  
    return t.viewImpendingFunc.isAvailable();
  },
  isFixFalseReportsAvailable : function (){
    var t = TowerAlerts;  
    return t.generateIncomingFunc.isAvailable();
  },
  
  
  postToChatOptions : {aChat:false},

  setPostToChatOptions : function (obj){
    var t = TowerAlerts;
    t.postToChatOptions = obj;
    clearTimeout(t.secondTimer);
  },

  e_buttonPostToChat : function (march){
    var t = TowerAlerts;
    t.postToChat (march, true);
    unsafeWindow.Modal.hideModal();
  },
  
  postToChat : function (m, force){
    var t = TowerAlerts;
    
    if (DEBUG_TRACE) logit ("checkTower(): ACHTUNG bei "+ unixTime()  +": \n"+ inspect (m, 8, 1));
    if (m.marchType == null)      // bogus march (returning scouts)
      return;
    if (ENABLE_TEST_TAB) Tabs.Test.addDiv ("ACHTUNG!<BR><PRE style='margin:0px;'>" + inspect (m, 8, 1) +'</pre>');
    if (m.marchType == 3){
      if (!t.postToChatOptions.scouting && !force)
        return;
      atkType = 'Gespäht';
    } else if (m.marchType == 4){
      atkType = 'Angegriffen';
    } else {
      return;
    }
    var target, atkType, who;
    var city = Cities.byID[m.toCityId];
    if ( city.tileId == m.toTileId )
      target = 'Stadt '+ city.x +','+ city.y;
    else {
      if (!t.postToChatOptions.wilds && !force)
        return;
      target = 'Wildniss';
      for (k in Seed.wilderness['city'+m.toCityId]){
        if (Seed.wilderness['city'+m.toCityId][k].tileId == m.toTileId){
          target += ' bei '+ Seed.wilderness['city'+m.toCityId][k].xCoord +','+ Seed.wilderness['city'+m.toCityId][k].yCoord;
          break;
        }
      }
    }
    if (Seed.players['u'+m.pid])
      who = Seed.players['u'+m.pid].n;
    else if (m.players && m.players['u'+m.pid])
      who = m.players['u'+m.pid].n;
    else
      who = 'Unbekannt';
  
    if (m.fromXCoord)
      who += ' bei '+ m.fromXCoord +','+ m.fromYCoord;
    var msg = '';
    if (!force)
      msg = t.postToChatOptions.aPrefix +' ';
    msg += 'Meine '+ target +' wird '+ atkType  +' von '+ who +' = Truppen Stärke (Ankunft in '+
        unsafeWindow.timestr(parseInt(m.arrivalTime - unixTime())) +') : ';
    var totTroops = 0;
    for (k in m.unts){
      var uid = parseInt(k.substr (1));
      msg += m.unts[k] +' '+ unsafeWindow.unitcost['unt'+uid][0] +', ';
      totTroops += m.unts[k];
    }
    if ((totTroops < t.postToChatOptions.minTroops) && !force)
      return;
    msg = msg.slice (0, -2);
    msg += '.';
    if ( city.tileId == m.toTileId ){
      var emb = getCityBuilding(m.toCityId, 8);
      if (emb.count > 0){
        var availSlots = emb.maxLevel;
        for (k in Seed.queue_atkinc){
          if (Seed.queue_atkinc[k].marchType==2 && Seed.queue_atkinc[k].toCityId==m.toCityId && Cities.byID[Seed.queue_atkinc[k].fromCityId]==null){
 //         if (Seed.queue_atkinc[k].marchType==2 && Cities.byID[Seed.queue_atkinc[k].fromCityId]==null){
            --availSlots;
          }
        }
        msg += ' = Meine Botschaft hat '+ availSlots +' von '+ emb.maxLevel +' Slots Frei!';
      }
    }
    if (ENABLE_TEST_TAB) Tabs.Test.addDiv (msg);
    if (SEND_ALERT_AS_WHISPER)
      sendChat ("/"+ Seed.player.name +' '+ msg);    // Whisper to myself
    else
      sendChat ("/a "+  msg);                        // Alliance chat
  },
  
}

function parseIntNan (n){
  x = parseInt(n, 10);
  if (isNaN(x))
    return 0;
  return x;
}
function parseIntZero (n){
  if (n == '')
    return 0;
  return parseInt(n, 10);
}

/*********************************** Players TAB ***********************************/

function officerId2String (oid){
  if (oid==null)
    return '';
  else if (oid==3)
    return 'Offizier';
  else if (oid==2)
    return 'Vize Kanzler';
  else if (oid==1)
    return 'Kanzler';
  return '';
}

Tabs.AllianceList = {
  tabOrder : 25,
  tabLabel : 'Spieler',
  cont : null,
  dat : [],

  

/***
ajax/viewCourt.php:
  (boolean) ok = true
  (array) courtItems =

  (string) dailyActionFlag = 0
  (object) playerInfo = [object Object]
    (string) datejoinUnixTime = 1294440708
    (string) truceExpireUnixTime = 0
    (string) userId = 4394121
    (string) displayName = Vakasade
    (string) email =
    (string) fbuid = 100000977751880
    (string) playerSex = F
    (string) usertype = 1
    (string) status = 1
    (string) dateJoined = 2011-01-07 14:51:48
    (string) lastLogin = 2011-03-13 13:11:34
    (string) eventTimestamp = 0000-00-00 00:00:00
    (string) eventStatus = 1
    (string) warStatus = 1
    (string) allianceId = 85
    (number) might = 1192710
    (string) title = 57
    (string) truceExpireTimestamp = 0000-00-00 00:00:00
    (string) fogExpireTimestamp = 0000-00-00 00:00:00
    (string) cnt_newmsg = 0
    (string) cnt_friendreq = 0
    (string) cnt_logins = 3910
    (string) cnt_passreset = 0
    (string) cnt_connections = 0
    (string) avatarId = 11
    (undefined) photo_host: null = null
    (undefined) photo_dir: null = null
    (undefined) photo_subdir: null = null
    (undefined) photo_name: null = null
    (string) allianceName = The Flying Circus

  (number) cityCount = 2
  (undefined) errorMsg: null = null
***/
fetchPlayerCourt : function (uid, notify){
  var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
  params.pid = uid;
  new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/viewCourt.php" + unsafeWindow.g_ajaxsuffix, {
    method: "post",
    parameters: params,
    onSuccess: function (rslt) {
logit ("ajax/viewCourt.php\n"+ inspect (rslt, 3, 1));      
      notify (rslt);
    },
    onFailure: function (rslt) {
      notify (rslt);
    },
  });
},


fetchTEST : function (pageNum, notify){    // as in alliance list, sorted by rank, 10 per page
  var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
  params.pageNo = 1;
  params.numPerPage = 100;
  params.perPage = 100;
  params.results = 100;
  params.numResults = 100;
  new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetMembersInfo.php" + unsafeWindow.g_ajaxsuffix, {
    method: "post",
    parameters: params,
    onSuccess: function (rslt) {
logit ("ajax/allianceGetMembersInfo.php:\n"+ inspect (rslt, 5, 1));      
      notify (rslt);
    },
    onFailure: function (rslt) {
      notify ({errorMsg:'AJAX error'});
    },
  });
},

  
   init : function (div){
    var t = Tabs.AllianceList;
    t.cont = div;
    unsafeWindow.PTgetMembers = t.eventGetMembers;
    unsafeWindow.PTpd = t.clickedPlayerDetail;
    unsafeWindow.PTpl = t.clickedPlayerLeaderboard;
    unsafeWindow.PTpl2 = t.clickedPlayerLeaderboard2;
    unsafeWindow.PTalClickPrev = t.eventListPrev;
    unsafeWindow.PTalClickNext = t.eventListNext;
	unsafeWindow.PCplo = t.clickedPlayerGetLastLogin;
	Lastlogin=0;
    t.show();
  },
 
 /*
  init : function (div){
    var t = Tabs.AllianceList;
    t.cont = div;
//t.fetchTEST();    
    unsafeWindow.PTgetMembers = t.eventGetMembers;
    unsafeWindow.PTpd = t.clickedPlayerDetail;
    unsafeWindow.PTpl = t.clickedPlayerLeaderboard;
    if (getMyAlliance()[0] == 0) {
      t.cont.innerHTML = '<BR><BR><CENTER>You need to be in an alliance to use this feature.</center>';
      t.state = 1;
      return;
    }
    var m = '<div ><DIV class=ptentry><TABLE width=100% cellpadding=0>\
        <TR><TD class=xtab align=right></td><TD class=xtab>Enter all or part of a player name: &nbsp;</td>\
          <TD width=80% class=xtab><INPUT id=allPlayName size=20 type=text /> &nbsp; <INPUT id=playSubmit type=submit value="Find Player" /></td>\
          <TD class="xtab ptErrText"><SPAN id=ptplayErr></span></td></tr>\
        <TR><TD class=xtab>OR: </td><TD class=xtab> Enter all or part of an alliance name: &nbsp;</td>\
          <TD class=xtab><INPUT id=allAllName type=text /> &nbsp; <INPUT id=allSubmit type=submit value="Find Alliance" /> &nbsp; <INPUT id=myAllSubmit type=submit value="'+ getMyAlliance()[1] +'" /></td>\
          <TD class="xtab ptErrText"><SPAN id=ptallErr></span></td></tr>\
        </table><span style="vertical-align:middle;" id=altInput></span></div>\
        <div style="overflow-y:auto;"; id=allListOut ></div></div>';
    t.cont.innerHTML = m;
    document.getElementById('allSubmit').addEventListener ('click', t.eventSubmit, false);
    document.getElementById('myAllSubmit').addEventListener ('click', t.eventMyAllianceSubmit, false);
    document.getElementById('playSubmit').addEventListener ('click', t.eventPlayerSubmit, false);
    document.getElementById('allAllName').addEventListener ('focus', function (){document.getElementById('ptallErr').innerHTML='';}, false);
    document.getElementById('allPlayName').addEventListener ('focus', function (){document.getElementById('ptplayErr').innerHTML='';}, false);
  },
*/
  hide : function (){
  },

  show : function (){
    var t = Tabs.AllianceList;
    if (t.state == null){
      if (getMyAlliance()[0] == 0) {
        t.cont.innerHTML = '<BR><BR><CENTER><blink>Du musst in einer Allianz sein um dieses Feature zu nutzen!</blink></center>';
        t.state = 1;
        return;
      }
      var m = '<DIV class=ptentry><TABLE width=100% cellpadding=0>\
          <TR><TD width="0%" align=right class=xtab></td><TD width="7%" class=xtab>Spieler Name: &nbsp;</td><TD width=11% class=xtab>&nbsp;</td>\
            <TD width=20% class=xtab><INPUT id=allPlayName size=20 type=text /> &nbsp; <INPUT id=playSubmit type=submit value="Spieler Finden" /></td>\
            <TD width="62%" class="xtab ptErrText"><SPAN id=ptplayErr></span></td></tr>\
          <TR><TD class=xtab> </td><TD class=xtab> Allianz Name: &nbsp;</td><TD class=xtab>&nbsp;</td>\
            <TD class=xtab><INPUT id=allAllName type=text /> &nbsp; <INPUT id=allSubmit type=submit value="Allianz Finden" /></td>\
            <TD class="xtab ptErrText"><SPAN id=ptallErr></span></td></tr><TR><TD class=xtab></td>\
             <TD class=xtab><INPUT align=left id=allListSubmit type=submit value="Alle Allianzen" /></td>\
             <TD class=xtab><INPUT align=left id=idMyAllSubmit type=submit value="'+ getMyAlliance()[1] +'"/></td>\
             <TD class=xtab><INPUT align=right id=allGotoPage type=submit value="Seite" />\
               <INPUT align=right id=idPageNum type="text" value='+t.curPage+' size=4 />\
             <span align=left id=idMaxPageNum ></span></td>\
             <TD class=xtab ><span><b><center>Ankunftszeit</center></b></span></td></tr>\
           <TR><TD height="43" class=xtab> </td><TD colspan="3" class=xtab><SPAN class=boldRed><u>Wichtig</u></span>: Die daten sind vom Leaderboard und können bis zu 24 Stunden alt sein!<br>\
<u><b>Hinweis</b></u>: Auf die Kopfspalte klicken zum Sortierten!<br>\
<b>ETA</b>: <i>estimated time of arrival</i> | voraussichtliche Ankunftszeit!</td>\
             <TD class=xtab ><div><center><select id="idFindETASelect">\
        <option value="0,250" >-- Auswählen --</option>\
        <option value="0,180" >Versorgungstruppe</option>\
        <option value="0,200" >Milizsoldat</option>\
        <option value="0,3000" >Späher</option>\
        <option value="0,300" >Lanzenträger</option>\
        <option value="0,275" >Schwertkämpfer</option>\
        <option value="0,250" >Bogenschütze</option>\
        <option value="1,1000" >Kavallerie</option>\
        <option value="1,750" >Schwere Kavallerie</option>\
        <option value="1,150" >Versorgungswagen</option>\
        <option value="1,100" >Ballisten</option>\
        <option value="1,120" >Rammbock</option>\
        <option value="1,80" >Steinschleuder</option>\
        </select></center></div>\
        </td></tr></table><span style="vertical-align:middle;" id=altInput></span></div><SPAN id=allListOut></span>';
      t.cont.innerHTML = m;
      document.getElementById('allSubmit').addEventListener ('click', t.eventSubmit, false);
      document.getElementById('playSubmit').addEventListener ('click', t.eventPlayerSubmit, false);
      document.getElementById('allAllName').addEventListener ('focus', function (){document.getElementById('ptallErr').innerHTML='';}, false);
      document.getElementById('allPlayName').addEventListener ('focus', function (){document.getElementById('ptplayErr').innerHTML='';}, false);
      document.getElementById('allListSubmit').addEventListener ('click', t.eventListSubmit, false);
      document.getElementById('allGotoPage').addEventListener ('click', t.gotoPage, false);
      document.getElementById('idMyAllSubmit').addEventListener ('click', t.showMyAlliance, false);
      document.getElementById('idFindETASelect').addEventListener ('click', t.handleEtaSelect, false);
      document.getElementById('allGotoPage').disabled = true;
      document.getElementById('idFindETASelect').disabled = true;
      t.ModelCity=Cities.cities[0];
      t.curPage = 0;
      t.MaxPage = -1;
      t.state = 1;
    }
  },

  pName : '',
  eventPlayerSubmit : function (){
    var t = Tabs.AllianceList;
    document.getElementById('ptplayErr').innerHTML='';
    var name = document.getElementById('allPlayName').value;
    t.pName = name;
    if (name.length < 3){
      document.getElementById('ptplayErr').innerHTML = '<span style="color:red"><blink>Mind. 3 Zeichen eingeben!</blink></span>';
      return;
    }
    document.getElementById('altInput').innerHTML = '';
    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>Durchsuche ...</center>';
    t.fetchPlayerList (name, t.eventGotPlayerList);
  },
  
  eventGotPlayerList : function (rslt){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      document.getElementById('allListOut').innerHTML = rslt.errorMsg;
      return;
    }
    t.playerList = rslt.matchedUsers;
    var uList = [];
    for (k in rslt.matchedUsers)
      uList.push (rslt.matchedUsers[k].userId);     
    t.fetchPlayerStatus (uList, function(r){t.eventGotPlayerOnlineList(r)});    
  },    
    
  eventGotPlayerOnlineList : function (rslt){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      document.getElementById('allListOut').innerHTML = rslt.errorMsg;
      return;
    }
    var m = '<DIV class=ptstat>Ergebniss: <B>"'+ t.pName +'"</b></div>\
      <DIV style="height:575px; max-height:575px; overflow-y:auto">\
      <TABLE width=100% align=center class=ptTab cellspacing=0><TR style="font-weight:bold"><TD>Name</td>\
      <TD align=right>Macht</td><TD> &nbsp; Online</td><TD> &nbsp;Facebook &nbsp; </td><TD width=75%>Anzeigen </td></tr>';
    var row=0;
    var cl='';
    for (k in t.playerList){
      var u = t.playerList[k];
      if (++row % 2)
        cl = 'class=ptOddrow ';
      else
        cl = '';
      m += '<TR '+ cl +'valign=top><TD>'+ u.genderAndName +'</td><TD align=right>'+ addCommasInt(u.might) +'</td>\
          <TD>'+ (rslt.data[u.userId]?"&nbsp;<SPAN class=boldDarkGreen><blink>ONLINE</blink></span>":"") +'</td>\
          <TD align=center><A target="_tab" href="http://www.facebook.com/profile.php?id='+ u.fbuid +'">Profil</a></td>\
          <TD><SPAN onclick="PTpd(this, '+ u.userId +')"><A>Details</a> &nbsp; <BR></span><SPAN onclick="PTpl2(this, \''+ u.userId +'\')"><A>Leaderboard</a><br></span><SPAN onclick="PCplo(this, '+ u.userId +')"><A>last Login</a></span></td></tr>';
    }
    m += '</table></div>';
    document.getElementById('allListOut').innerHTML = m;
  },
  gotPlayerLastLogin : function (rslt, span){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      span.innerHTML = rslt.errorMsg;
      return;
    }

    var p = rslt.playerInfo;
    var lastLogin = rslt.playerInfo.lastLogin;
    
    if (lastLogin) {
      m = '<span style="color:black">Letzter Login: '+lastLogin+'</span>';
    } else {
       m = '<span style="color:red">Keine Logindaten gefunden: '+lastLogin+'</span>';
    }  
    span.innerHTML = m + '';
  },
  fetchPlayerLastLogin : function (uid, notify){
var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
params.pid = uid;
new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/viewCourt.php" + unsafeWindow.g_ajaxsuffix, {
method: "post",
parameters: params,
onSuccess: function (rslt) {
notify (rslt);
},
onFailure: function (rslt) {
notify ({errorMsg:'AJAX error'});
},
});
},  
  clickedPlayerDetail : function (span, uid){
    var t = Tabs.AllianceList;
    span.onclick = '';
    span.innerHTML = "suche details ...";
    t.fetchPlayerInfo (uid, function (r) {t.gotPlayerLastLogin(r, span)});
  },

  clickedPlayerLeaderboard : function (span, uid){
    var t = Tabs.AllianceList;
    span.onclick = '';
    span.innerHTML = "suche leaderboard info ...";
    t.fetchLeaderboard (uid, function (r) {t.gotPlayerLeaderboard(r, span)});
  },
  clickedPlayerLeaderboard2 : function (span, uid){
    var t = Tabs.AllianceList;
    span.onclick = '';
    span.innerHTML = "suche leaderboard info ...";
    t.fetchLeaderboard (uid, function (r) {t.gotPlayerLeaderboard2(r, span,uid)});
  },
  clickedPlayerGetLastLogin : function (span, uid){
    var t = Tabs.AllianceList;
  var s = Tabs.Search;
    span.onclick = '';
    span.innerHTML = "suche login date ...";
    t.fetchPlayerLastLogin (uid, function (r) {s.gotPlayerLastLogin(r, span)});
  },
  gotPlayerLeaderboard2 : function (rslt,span){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      span.innerHTML = rslt.errorMsg;
      return;
    }
    if (rslt.totalResults == 0){
      span.innerHTML = '<B>Leaderboard:</b> nicht gefunden... :/! (evtl. im Nebel ?)';
      return;
    }
    var myA = getMyAlliance ();
    t.dat = [];
    //logit ("gotPlayerLeaderboard2 -1 "+JSON2.stringify(rslt));
    var p = rslt.results[0];
        if ( myA[0] == p.allianceId)
           t.friendEta = true;
        else
           t.friendEta = false;
        for (var c=0; c<p.cities.length; c++){
          t.dat.push ([p.displayName, parseInt(p.might), p.officerType, parseInt(p.numCities), parseInt(p.cities[c].tileLevel),
               parseInt(p.cities[c].xCoord), parseInt(p.cities[c].yCoord), p.cities[c].cityName, 0, 1,0,p.userId]);
        }
        t.setDistances (Cities.cities[0].x, Cities.cities[0].y);
        t.ModelCity=Cities.cities[0];
        t.setEta();
        t.displayPlayer ();
		t.fetchPlayerLastLogin (uid, function (r) {t.displayPlayer(p.allianceName,r)});
  },
  
  
  gotPlayerLeaderboard : function (rslt, span){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      span.innerHTML = rslt.errorMsg;
      return;
    }
    if (rslt.totalResults == 0){
      span.innerHTML = '<B>Leaderboard:</b> nicht gefunden... :/! (evtl. im Nebel ?)';
      return;
    }
    var p = rslt.results[0];
    var an = p.allianceName;
    if (!an || an=='' || p.officerType==4)
      an = 'none';
    else
      an += ' ('+ officerId2String(p.officerType) +')';
    pStr = JSON2.stringify(p);
    logit (pStr);
    m = '<TABLE cellspacing=0 class=ptTab><TR><TD><B>Leaderboard: </b></td><TD colspan=2> Macht: '+ p.might  +' &nbsp; Allianz: '+ an +'</td></tr>';
    for (var i=0; i<p.cities.length; i++){
      var c = p.cities[i];
      var created = '';
      if (c.dateCreated && c.dateCreated.substr(0,2)=='20')
        created = ' &nbsp; Erstellt: ' + c.dateCreated.substr(0,10);
      m += '<TR><TD align=right><B>Stadt #'+ (i+1) +':</b></td><TD> &nbsp; '+ c.cityName
      +' (<a onclick="ptGotoMap ('+ c.xCoord +',' +c.yCoord+ ')">'+ c.xCoord +','+ c.yCoord +'</a>)</td><TD width=75%> &nbsp; Level: '
        + c.tileLevel +' &nbsp; Status: '+ cityStatusString (c.cityStatus) + created +'</td></tr>';
    }  
    span.innerHTML = m + '</table>';
  },
    
  gotPlayerDetail : function (rslt, span){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      span.innerHTML = rslt.errorMsg;
      return;
    }
    var u = rslt.userInfo[0];
    var a = 'None';
    if (u.allianceName)
      a = u.allianceName +' ('+ getDiplomacy(u.allianceId) + ')';
    var m = '<TABLE cellspacing=0 class=ptTab><TR><TD><B>Details:</b> &nbsp; </td><TD>Allianz: '+ a +' &nbsp; Städte: '
          + u.cities +' &nbsp; Bevölkerung: '+ u.population +'</td></tr><TR><TD></td><TD>Provinzen: ';
    var pids = u.provinceIds.split (',');
    var p = [];
    for (var i=0; i<pids.length; i++)
      p.push(unsafeWindow.provincenames['p'+pids[i]]);
    span.innerHTML = m + p.join (', ') +'</td></tr></table>';
  },

  eventMyAllianceSubmit : function (){
    var t = Tabs.AllianceList;
    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>Durchsuche ...</center>';
    t.fetchAllianceMemberList (getMyAlliance()[0], null, t.eventGotMemberList);
  },  
    
  aName : '',
  eventSubmit : function (){
    var t = Tabs.AllianceList;
    document.getElementById('ptallErr').innerHTML='';
    t.aName = document.getElementById('allAllName').value;
    if (t.aName.length < 3){
      document.getElementById('ptallErr').innerHTML = '<span style="color:red"><blink>Mind. 3 Zeichen eingeben!</blink></span>';
      return;
    }
    var myA = getMyAlliance ();
    document.getElementById('altInput').innerHTML = '';
    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>Durchsuche ...</center>';
    if (myA[0]!=0 && myA[1].toLowerCase().indexOf(t.aName.toLowerCase())>=0 )
      t.fetchAllianceList (t.aName, myA[0], t.eventGotAllianceList);
    else
      t.fetchAllianceList (t.aName, null, t.eventGotAllianceList);
  },

  eventListSubmit : function (){
    var t = Tabs.AllianceList;
    var myA = getMyAlliance ();
    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>Durchsuche Leaderboard nach Allianz Informationen...</center>';
    if (myA[0]!=0  ) {
       t.curPage=1;
       t.fetchOtherAllianceInfo ( 1, t.eventGotOtherAlliancePage);
       document.getElementById('allGotoPage').disabled = false;
    }
    else {
       document.getElementById('allListOut').innerHTML = '<blink>Du musst in einer Allianz sein um dieses Feature zu nutzen!</blink>';
    }
  },

  eventGotAllianceList : function (rslt){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      document.getElementById('allListOut').innerHTML = rslt.errorMsg;
      return;
    }
    var m = '<DIV class=ptstat>Ergebniss: <B>"'+ t.aName +'"</b></div>\
    <TABLE><TR style="font-weight:bold"><TD class=xtab>Allianz Name</td><TD class=xtab>Rank</td><TD class=xtab>Spieler</td>\
        <TD align=right class=xtab>Macht</td><TD class=xtab>Diplomatie</td><TD class=xtab></td></tr>';
    for (k in rslt.alliancesMatched){
      var all = rslt.alliancesMatched[k];
      var dip = '';
      if (all.relation && all.relation==1)
        dip = 'Freundlich';
      else if (all.relation && all.relation==2)
        dip = 'Feindlich';
      m += '<TR><TD class=xtab>'+ all.allianceName +'</td><TD align=right class=xtab>'+ all.ranking +'</td><TD align=right class=xtab>'+ all.membersCount +'</td>\
       <TD align=right class=xtab>'+ addCommasInt(all.might) +'</td><TD class=xtab>'+ dip +'</td>\
       <TD class=xtab><a onclick="PTgetMembers('+ all.allianceId +')">Spieler Anzeigen</a></td></tr>';
    }
    document.getElementById('allListOut').innerHTML = m;
  },


  showMyAlliance : function (){
    var t = Tabs.AllianceList;
    var myA = getMyAlliance ();
    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>Durchsuche Leaderboard nach Allianz Informationen...</center>';
    if (myA[0]!=0  ) {
       t.eventGetMembers(myA[0]);
    }
    else {
       document.getElementById('allListOut').innerHTML = '<blink>Du musst in einer Allianz sein um dieses Feature zu nutzen!</blink>';
    }
  },

  curPage : 0,
  MaxPage : 0,

  eventListNext : function (amt){
    var t = Tabs.AllianceList;
    if( parseInt(amt) >= 9999 )
       t.curPage = t.MaxPage;
    else {
       t.curPage = parseInt(t.curPage) + parseInt(amt);
       if ( t.curPage > t.MaxPage) {
         t.curPage = t.MaxPage;
       }
    }
    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>Durchsuche Leaderboard nach Allianz Informationen...</center>';
    t.fetchOtherAllianceInfo (t.curPage, t.eventGotOtherAlliancePage);
  },

  eventListPrev : function (amt){
    var t = Tabs.AllianceList;
    if(amt <= -1)
       t.curPage = 1;
    else {
       t.curPage-=amt;
       if ( t.curPage < 1 ) {
         t.curPage = 1;
       }
    }
    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>Durchsuche Leaderboard nach Allianz Informationen...</center>';
    t.fetchOtherAllianceInfo (t.curPage, t.eventGotOtherAlliancePage);
  },

  gotoPage : function (){
    var t = Tabs.AllianceList;
    var val = document.getElementById('idPageNum').value;
    if (t.MaxPage < 0 ) {
      document.getElementById('allListOut').innerHTML = 'Allianzen als erstes auflisten';
      return;
    }
    if (t.MaxPage < 0 || val > t.MaxPage || val < 1) {
      document.getElementById('allListOut').innerHTML = 'Seite Nummer existiert nicht!';
      return;
    }
    t.curPage = val;
    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>Durchsuche Leaderboard nach Allianz Informationen...</center>';
    t.fetchOtherAllianceInfo (t.curPage, t.eventGotOtherAlliancePage);
  },

  eventGotOtherAlliancePage : function (rslt){
    var t = Tabs.AllianceList;

    if (!rslt.ok){
      document.getElementById('allListOut').innerHTML = rslt.errorMsg;
      return;
    }

    document.getElementById('idPageNum').value = t.curPage;

    t.MaxPage=rslt.noOfPages;
    document.getElementById('idMaxPageNum').innerHTML = 'von ' + t.MaxPage;

    var m = '<div style="overflow:auto; height:556px;width:564px;"><TABLE><thead><TR style="font-weight:bold"> \
        <th class=xtab>Allianz Name</th><th class=xtab>Rang</th><th class=xtab>Spieler</th>\
        <th align=right class=xtab>Macht</th><th class=xtab>Diplomatie</th><th class=xtab></th></tr></thead><tbody>';
    document.getElementById('allListOut').innerHTML = m;

    for (var i=0; i<rslt.otherAlliances.length; i++) {
      var alliance = rslt.otherAlliances[i];
      var dip = '';
      dip = getDiplomacy2(alliance.allianceId);

      m += '<TR class="'+ dip + '"><TD class=xtab>' + alliance.name +'</td><TD align=right class=xtab>'+ alliance.ranking +'</td><TD align=right class=xtab>'+ alliance.membersCount +'</td>\
       <TD align=right class=xtab>'+ addCommasInt(alliance.might) +'</td><TD class=xtab>'+ dip +'</td>\
       <TD class=xtab><a onclick="PTgetMembers('+ alliance.allianceId +')">Spieler Anzeigen</a></td></tr>';
    }
    m += '</tbody></TABLE><div style="font-weight:bold"; height:20px;width:560px; ><span> <a onclick="PTalClickPrev(-1)"> [Top 10] </a><a onclick="PTalClickPrev(10)"> [-10] </a><a onclick="PTalClickPrev(5)"> [-5] </a><a onclick="PTalClickPrev(1)"> [zurück] </a> \
          <a onclick="PTalClickNext(1)"> [weiter] </a><a onclick="PTalClickNext(5)"> [+5] </a><a onclick="PTalClickNext(10)"> [+10] </a><a onclick="PTalClickNext(9999)"> [Ende] </a> </span></div>';
    m += '</div>';
    document.getElementById('allListOut').innerHTML = m;
 },

  showCurrentPage : function (){
    var t = Tabs.AllianceList;
    var myA = getMyAlliance ();

    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER> ...</center>';
    if (myA[0]!=0  ) {
       t.fetchOtherAllianceInfo ( t.curPage, t.eventGotOtherAlliancePage);
    }
    else {
       t.fetchOtherAllianceInfo ( t.curPage, t.eventGotOtherAlliancePage);
    }

  },

  eventGotMemberList : function (rslt){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      document.getElementById('allListOut').innerHTML = rslt.errorMsg;
      return;
    }
    t.memberListRslt = rslt;
    var uList = [];
    for (k in rslt.results)
      uList.push (rslt.results[k].userId);     
    t.fetchPlayerStatus (uList, function(r){t.eventGotMemberOnlineList(r)});    
  },    
    
  eventGotMemberOnlineList : function (rslt){
    var t = Tabs.AllianceList;
    var numInvalid = 0;
    var numPlayers = 0;
    var myA = getMyAlliance ();
    t.dat = [];
    for (var i=0; i<t.memberListRslt.results.length; i++){
      p = t.memberListRslt.results[i];
      if (p.userId == 0){
        ++numInvalid;
      } else {
        ++numPlayers;
        if ( myA[0] == p.allianceId)
           t.friendEta = true;
        else
           t.friendEta = false;
        for (var c=0; c<p.cities.length; c++){
          t.dat.push ([p.displayName, parseInt(p.might), p.officerType, parseInt(p.numCities), parseInt(p.cities[c].tileLevel),
               parseInt(p.cities[c].xCoord), parseInt(p.cities[c].yCoord), p.cities[c].cityName, 0, rslt.data[p.userId]?1:0,'NA',p.userId]);
        }
      }
    }
    t.setDistances (Cities.cities[0].x, Cities.cities[0].y);
    t.ModelCity=Cities.cities[0];
    t.setEta();
    t.displayMembers (t.memberListRslt.allianceName, numPlayers);
  },

  // sort and display
  reDisp : function (){
    var t = Tabs.AllianceList;
    function sortFunc (a, b){
      var t = Tabs.AllianceList;
      if (typeof(a[t.sortColNum]) == 'number'){
        if (t.sortDir > 0)
          return a[t.sortColNum] - b[t.sortColNum];
        else
          return b[t.sortColNum] - a[t.sortColNum];
      } else if (typeof(a[t.sortColNum]) == 'boolean'){
// TODO !!        
return 0;        
      } else {
        if (t.sortDir > 0)
          return a[t.sortColNum].localeCompare(b[t.sortColNum]);
        else
          return b[t.sortColNum].localeCompare(a[t.sortColNum]);
      }
    }
    t.dat.sort (sortFunc);
    var m = '';
    for (var i=0; i<t.dat.length; i++){
      m += '<TR style="max-height:30px"><TD class=xxtab>'+ t.dat[i][0] +'</td><TD align=right class=xxtab>'+ addCommasInt(t.dat[i][1])
         +'</td><TD align=center class=xxtab>'+ t.dat[i][3] +'</td><TD class=xxtab>'+ officerId2String(t.dat[i][2])                       
         +'</td><TD class=xxtab>'+ (t.dat[i][9]?'<SPAN class=boldDarkGreen><blink>ONLINE</blink></span>':'') +'</td><TD class=xxtab>'+ t.dat[i][7] +'</td><TD align=right class=xxtab>'+ t.dat[i][4]
         +'</td><TD align=center class=xxtab><DIV onclick="ptGotoMap('+ t.dat[i][5] +','+ t.dat[i][6] +')"><A>'+ t.dat[i][5] +','+ t.dat[i][6] +'</a></div></td>\
            <TD align=right class=xxtab style="padding-right:20px;">'+ t.dat[i][8].toFixed(2) +'</td>\
         </td><TD  nowrap class=xxtab>'+ (t.dat[i][10]?'<SPAN>'+ (t.dat[i][10]>0?timestr(t.dat[i][10],1):'NA') +'</span>':'<SPAN>NA</span>') +'<td class=xxtab><SPAN onclick="PCplo(this, \''+ t.dat[i][11] +'\')"><A>last Login</a></span><td></tr>';
    }
    var tbody = document.getElementById('allBody');
    tbody.style.maxHeight = '';
    tbody.innerHTML = m;


    if (parseInt(tbody.clientHeight) > 470){
      tbody.style.height = '470px';
      tbody.style.maxHeight = '470px';
    }
//new CtableToText('tabAllMembers').toText();
  },


  setDistances : function (x, y){
    var t = Tabs.AllianceList;
    for (var i=0; i<t.dat.length; i++)
      t.dat[i][8] = distance (x, y, t.dat[i][5], t.dat[i][6]);
  },

  friendEta:false,

  setEta : function (){
    var t = Tabs.AllianceList;
    for (var i=0; i<t.dat.length; i++) {
      if (t.dat[i][8]) {
        var eta = t.estETA(parseFloat(t.dat[i][8]));
        if (t.friendEta)
           t.dat[i][10] = eta.friendETA;
        else
           t.dat[i][10] = eta.ETA;
      }
    }
  },



  handleEtaSelect : function (){
    var t = Tabs.AllianceList;
    t.setEta();
    t.reDisp();
  },

  sortColNum : 8,
  sortDir : 1,

  displayMembers : function (allName, numPlayers){
    var t = Tabs.AllianceList;
    function alClickSort (e){
      var t = Tabs.AllianceList;
      var newColNum = e.id.substr(8);
      document.getElementById('clickCol'+t.sortColNum).className = 'clickable';
      e.className='clickable clickableSel';
      if (newColNum == t.sortColNum)
        t.sortDir *= -1;
      else
        t.sortColNum = newColNum;
      t.reDisp();
    }
   unsafeWindow.PCplo = t.clickedPlayerGetLastLogin;
    unsafeWindow.PTalClickSort = alClickSort;
    var m = '<STYLE>.clickable{background-color:#ddd; border:2px outset; border-color:#555; padding-left:5px; padding-right:5px}\
            .clickableSel{background-color:#ffffcc;}\
            .xxtab{background-color:none; padding-left:5px; padding-right:5px;} </style>\
      <DIV class=ptstat ><TABLE id=tabAllMembers cellpadding=0  width=100%><TR font-weight:bold"><TD class=xtab> &nbsp; '+ allName +'</td>\
        <TD class=xtab width=80% align=center>Entfernung von <SPAN id=distFrom>'+ Cities.cities[0].name +' <b>('+ Cities.cities[0].x +','+ Cities.cities[0].y +')</b></span></td><TD class=xtab align=right>'+ numPlayers +' players found &nbsp; </td></tr></table></div>\
      <div style="max-height:470px; height:470px; overflow-y:auto;"><TABLE id=tabAllMembers align=center cellpadding=0 cellspacing=0><THEAD style="overflow-y:hidden;">\
      <TR style="font-weight:bold"><TD id=clickCol0 onclick="PTalClickSort(this)" class=clickable><A><DIV>Spieler</div></a></td>\
        <TD id=clickCol1 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>Macht</a></div></td>\
        <TD id=clickCol3 onclick="PTalClickSort(this)" class=clickable><A><DIV>#</a></div></td>\
        <TD id=clickCol2 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>Rang</a></div></td>\
        <TD id=clickCol9 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>Online</a></div></td>\
        <TD id=clickCol7 onclick="PTalClickSort(this)" class=clickable><A><DIV>Stadt Name</a></div></td>\
        <TD id=clickCol4 onclick="PTalClickSort(this)" class=clickable><A><DIV>Level</a></div></td>\
        <TD id=clickCol5 onclick="PTalClickSort(this)" class=clickable><A><DIV>Koordinate</a></div></td>\
        <TD id=clickCol8 onclick="PTalClickSort(this)" class=clickable><A><DIV>Entf.</a></div></td>\
       <TD id=clickCol10 onclick="PTalClickSort(this)" class=clickable><A><DIV>Eta</a></div></td>\
         <TD class=clickable><A><DIV>Last Login</a></div></td></tr></thead>\
       <TBODY id=allBody style="background-color:#ffffff;"></tbody></table></div>';
    document.getElementById('allListOut').innerHTML = m;//style="top:670px; left:0px; position:absolute;
    document.getElementById('altInput').innerHTML = '<HR><TABLE width=100% cellpaddding=0><TR align=center>\
        <TD class=xtab>Entfernung von: &nbsp; X: <INPUT size=2 type=text id=plyrX /> Y: <INPUT size=2 type=text id=plyrY /> <span id=dmcoords></span></td></tr></table>';
    document.getElementById('clickCol'+t.sortColNum).className = 'clickable clickableSel';

    t.reDisp();
    new CdispCityPicker ('plyrdcp', document.getElementById ('dmcoords'), true, t.eventCoords, 0).bindToXYboxes(document.getElementById('plyrX'), document.getElementById('plyrY'));
    document.getElementById('idFindETASelect').disabled = false;
  },
  
  displayPlayer : function (allName,rslt){
    var t = Tabs.AllianceList;
    function alClickSort (e){
      var t = Tabs.AllianceList;
      var newColNum = e.id.substr(8);
      document.getElementById('clickCol'+t.sortColNum).className = 'clickable';
      e.className='clickable clickableSel';
      if (newColNum == t.sortColNum)
        t.sortDir *= -1;
      else
        t.sortColNum = newColNum;
      t.reDisp();
    }
    unsafeWindow.PTalClickSort = alClickSort;
    var m = '<STYLE>.clickable{background-color:#ddd; border:2px outset; border-color:#555; padding-left:5px; padding-right:5px}\
            .clickableSel{background-color:#ffffcc;}\
            .xxtab{background-color:none; padding-left:5px; padding-right:5px;} </style>\
			<DIV class=ptstat ><TABLE id=tabAllMembers cellpadding=0  width=100%><TR font-weight:bold"><TD class=xtab>Alliance: '+ allName +'</td>\
			<TD class=xtab width=80% align=center>Last login: <SPAN id=lastlogin>'+  rslt.playerInfo.lastLogin+'</span></td><TD class=xtab align=right></td></tr></table></div>\
      <div style="max-height:470px; height:470px; overflow-y:auto;"><TABLE id=tabAllMembers align=center cellpadding=0 cellspacing=0><THEAD style="overflow-y:hidden;">\
<TR style="font-weight:bold"><TD id=clickCol0 onclick="PTalClickSort(this)" class=clickable><A><DIV>Spieler</div></a></td>\
        <TD id=clickCol1 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>Macht</a></div></td>\
        <TD id=clickCol3 onclick="PTalClickSort(this)" class=clickable><A><DIV>#</a></div></td>\
        <TD id=clickCol2 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>Rang</a></div></td>\
        <TD id=clickCol9 onclick="PTalClickSort(this)" class=clickable align=center><A><DIV>Online</a></div></td>\
        <TD id=clickCol7 onclick="PTalClickSort(this)" class=clickable><A><DIV>Stadt Name</a></div></td>\
        <TD id=clickCol4 onclick="PTalClickSort(this)" class=clickable><A><DIV>Level</a></div></td>\
        <TD id=clickCol5 onclick="PTalClickSort(this)" class=clickable><A><DIV>Koordinate</a></div></td>\
        <TD id=clickCol8 onclick="PTalClickSort(this)" class=clickable><A><DIV>Entf.</a></div></td>\
        <TD id=clickCol10 onclick="PTalClickSort(this)" class=clickable><A><DIV>ETA</a></div></td></tr>\
      <TD class=clickable><DIV><A>Last Login</a></div></td></tr></thead>\
      <TBODY id=allBody style="background-color:#ffffff;"></tbody></table></div>';
    document.getElementById('allListOut').innerHTML = m;//style="top:670px; left:0px; position:absolute;
    document.getElementById('altInput').innerHTML = '<HR><TABLE width=100% cellpaddding=0><TR align=center>\
        <TD class=xtab>Entfernung von: &nbsp; X: <INPUT size=2 type=text id=plyrX /> Y: <INPUT size=2 type=text id=plyrY /> <span id=dmcoords></span></td></tr></table>';
    document.getElementById('clickCol'+t.sortColNum).className = 'clickable clickableSel';

    t.reDisp();
    new CdispCityPicker ('plyrdcp', document.getElementById ('dmcoords'), true, t.eventCoords, 0).bindToXYboxes(document.getElementById('plyrX'), document.getElementById('plyrY'));
    document.getElementById('idFindETASelect').disabled = false;
  },
  
  eventCoords : function (city, x, y){
    var t = Tabs.AllianceList;
    var m = '';
    if (city != null)
      m = city.name +' ('+ city.x +','+ city.y +')';
    else
      m = x +','+ y;
    var distFrom = document.getElementById('distFrom');
    if (distFrom)
        distFrom.innerHTML = m;
    t.ModelCity=city;
    t.setDistances(x,y);
    t.setEta();
    t.reDisp();
  },

  eventGetMembers : function (aid){
    var t = Tabs.AllianceList;
    document.getElementById('allListOut').innerHTML = '<BR><BR><CENTER>Durche Leader Board nach Spieler Informationen...</center>';
    t.fetchAllianceMemberList (aid, null, t.eventGotMemberList);
  },

  fetchAllianceMemberList : function (allianceId, allianceName, notify) {
    var t = Tabs.AllianceList;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.perPage = 100;
    if (allianceName)
      params.allianceName = allianceName;
    if (allianceId && allianceId != 0)
      params.allianceId = allianceId;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserLeaderboard.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },

  fetchLeaderboard : function (uid, notify) {
    var t = Tabs.AllianceList;
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.userId = uid;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserLeaderboard.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },

  fetchAllianceList : function (allianceName, myAid, notify) {   // at least 3 chars :)
    var t = Tabs.AllianceList;
    function combineResults (rsltA, rsltM, notify){
      if (!rsltA.ok){
        if (rsltA.msg.indexOf("keine Allianz unter")!=0 || !rsltM.ok){
          notify (rsltA);
          return;
        }
        rsltA.ok = true;
        rsltA.count = 0;
        rsltA.alliancesMatched = {};
      }
      if (rsltM.ok){
        rsltA.alliancesMatched['a'+rsltM.allianceInfo.allianceId] = {allianceId: rsltM.allianceInfo.allianceId, allianceName: rsltM.allianceInfo.allianceName,
              membersCount: rsltM.allianceInfo.members, relation: null, might: rsltM.allianceInfo.might, ranking: rsltM.allianceInfo.ranking};
        ++rsltA.count;
      }
      notify (rsltA);
    }
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.allianceName = allianceName;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetSearchResults.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (myAid!=null && myAid>0)
          t.fetchMyAllianceInfo  (function (r){ combineResults (rslt, r, notify)});
        else
          notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },

  fetchOtherAllianceInfo : function (pageNum, notify){    // as in alliance list, sorted by rank, 10 per page
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.pageNo = pageNum;
    params.cityId = unsafeWindow.currentcityid;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetOtherInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },

  fetchMyAllianceInfo : function (notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/allianceGetInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },

  fetchPlayerList : function (name, notify){  // at least 3 chars!!
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.searchName = name;
    params.subType = "ALLIANCE_INVITE";
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/searchPlayers.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },

  fetchPlayerInfo : function (uid, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.uid = uid;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getUserGeneralInfo.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },
  
/***
ajax/getOnline.php:
  (string) ok = true
  (object) data = [object Object]
    (boolean) 4394121 = false
  (undefined) errorMsg: null = null
***/
  fetchPlayerStatus : function (uidArray, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.checkArr = uidArray.join(',');
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getOnline.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },

  ModelCity : {},

  estETA : function(dist) { // Need Relief Station Levels to estimate transport, reinf, or reassign times.
    var t = Tabs.AllianceList;
    var ret={ETA:0,etaStr:'NA',friendETA:0,friendEtaStr:'NA'};    
    var cityID;
    if (dist <= 0) return ret;
    var EtaType = document.getElementById('idFindETASelect');
    var baseSpeedSel = EtaType.options[EtaType.selectedIndex].value;
    var m = baseSpeedSel.split(',');
    var horse = 0;
    var baseSpeed = 0;
    if(m) {
      horse = parseInt(m[0]);
      baseSpeed = parseInt(m[1]);
    }
    if (baseSpeed == 0) return ret;
    var mmLvl = parseInt(Seed.tech.tch11);//Magical Mapping
    var Speed = 0;
    if (horse){
   //HorsesSiegeSpeed = Base * (1 + MM/10) * (1 + AH/20)
      var hsLvl = parseInt(Seed.tech.tch12);//Alloy Horse Shoes
      Speed = baseSpeed * (1 + mmLvl/10.0) * (1 + hsLvl/20.0);
    }
    else {
    //FootSpeed = Base * (1 + MM/10)
      Speed = baseSpeed * (1 + mmLvl/10.0);
    }
    //Grid Speed (tiles/second) = Speed (100ths/min) / 6000
    var gSpeed = 0;
    var estSec;
    if (Speed>0) {
      gSpeed = Speed/6000.0;//0.48333 mm=10, hs=9
      estSec = (parseFloat(dist)/gSpeed).toFixed(0);
    }
    ret.ETA = (parseInt((estSec+''))+30);
    ret.etaStr = timestr (ret.ETA,1);
    //ret.etaStr = ret.ETA + ', ' + timestr (ret.ETA,1);
    //RS - Cities Relief Station Level
    //Friendly Speed = Speed * (1 + RS/2)
    if (t.ModelCity) {
      cityID = t.ModelCity.id;
      var building = getCityBuilding (cityID, 18);
      if (building) {
        fSpeed = Speed * (1 + parseInt(building.maxLevel)/2);
        gSpeed = fSpeed/6000;
        estSec = (dist/gSpeed).toFixed(0);
        ret.friendETA = parseInt((estSec+''))+30;
        ret.friendEtaStr = timestr ((ret.friendETA+''),1);
      }
   }
    return ret;
  },
};


/*********************************** Fake TAB ***********************************/

Tabs.F = {
  tabOrder : 100,
  tabLabel : 'FA',
  tabDisabled : !ENABLE_TEST_TAB,
  cont : null,

  init : function (div){
    var t = Tabs.F;
    t.cont = div;
   var citySelect = '   <SELECT id=fakeCity>';
       for (var c=0; c<Cities.numCities; c++) {
           aCity = Cities.cities[c].name + ' ('+Cities.cities[c].x + ','+ Cities.cities[c].y+')';
            citySelect += '<option value=\''+c+'\'>'+aCity+'</option>';
       }
       citySelect += '</select>';
    var m = '<TABLE><TR><TD align=right>Späh Angriff: </td><TD><INPUT type=checkbox id=fakeIsScout></td></tr>\
        <TR><TD align=right>Wildniss Angreifen: </td><TD><INPUT type=checkbox id=fakeIsWild></td></tr>\
        <TR><TD align=right>Fake Bericht: </td><TD><INPUT type=checkbox disabled id=fakeFalse></td></tr>\
        <TR><TD align=right>Sekunden: </td><TD><INPUT type=text size=4 value=300 id=fakeSeconds></td></tr>\
        <TR><TD align=right>Versorgungstruppe: </td><TD><INPUT type=text size=6 value=0 id=fakeSupply></td></tr>\
    <TR><TD align=right>Milizsoldat: </td><TD><INPUT type=text size=6 value=5000 id=fakeMilitia></td></tr>\
    <TR><TD align=right>Späher: </td><TD><INPUT type=text size=6 value=0 id=fakeScout></td></tr>\
      <TR><TD align=right>Lanzenträger: </td><TD><INPUT type=text size=6 value=0 id=fakePike></td></tr>\
      <TR><TD align=right>Schwertkämpfer: </td><TD><INPUT type=text size=6 value=0 id=fakeSword></td></tr>\
      <TR><TD align=right>Bogenschütze: </td><TD><INPUT type=text size=6 value=0 id=fakeArcher></td></tr>\
      <TR><TD align=right>Kavallerie: </td><TD><INPUT type=text size=6 value=0 id=fakeCav></td></tr>\
      <TR><TD align=right>Schwere Kavallerie: </td><TD><INPUT type=text size=6 value=0 id=fakeHeavy></td></tr>\
      <TR><TD align=right>Versorgungswagen: </td><TD><INPUT type=text size=6 value=0 id=fakeWagon></td></tr>\
      <TR><TD align=right>Ballisten: </td><TD><INPUT type=text size=6 value=0 id=fakeBallista></td></tr>\
      <TR><TD align=right>Rammbock: </td><TD><INPUT type=text size=6 value=0 id=fakeRam></td></tr>\
      <TR><TD align=right>Steinschleuder: </td><TD><INPUT type=text size=6 value=0 id=fakeCat></td></tr>\
      <TR><TD align=right>Fake Name: </td><TD><INPUT type=text size=13 value=FAKE_ANGRIFF id=fakeName></td></tr>\
      <TR><TD align=right>Ziel: </td><TD>'+citySelect+'</td></tr>\
        <TR><TD colspan=2 align=center><INPUT id=testSendMarch type=submit value="Fake Angriff" \></td></tr></table>\
        <INPUT id=ptReloadKOC type=submit value="Refresh KoC" \>\
        <BR><DIV id=testDiv style="background-color:#fffff0; maxwidth:675; max-height:430px; height:430px; overflow-y:auto;"></div>';
    t.cont.innerHTML = m;
    document.getElementById('testSendMarch').addEventListener ('click', t.clickFakeAttack, false);
    document.getElementById('ptReloadKOC').addEventListener ('click', t.reloadKOC, false);
    function xyNotify(city, x, y){
      var m = '[ Notified: '+ (city?city.name:'null') +', x='+ x +', y='+ y +' ]';
      document.getElementById('testNotify').innerHTML = m;
    }
  },

  hide : function (){
  },

  show : function (){
  },
  
  reloadKOC : function (){
    window.location.href = '';
    setTimeout (function (){window.location.href = window.location.href +'&rload=3';}, 0);
    var goto = 'http://apps.facebook.com/kingdomsofcamelot/?s='+getServerId();
    var t = '<FORM target="_top" action="'+ goto +'" method=post><INPUT id=xxButReload type=submit value=RELOAD><INPUT type=hidden name=s value="'+ getServerId() +'"</form>';
    var e = document.createElement ('div');
    e.innerHTML = t;
    document.body.appendChild (e);
    setTimeout (function (){document.getElementById('xxButReload').click();}, 0);
  },
  
  writeDiv : function (msg){
    var t = Tabs.F
    if (t.state != null)
      document.getElementById('testDiv').innerHTML = msg;
  },

  addDiv : function (msg){
    var t = Tabs.F;
    if (t.state != null)
      document.getElementById('testDiv').innerHTML += msg;
  },

  createFakeAttack : function (cityNum, isScout, isWild, isFalse, secs, numMilitia, numSupply, numPike,numSword,numArcher,numCav,numHeavy,numWagon,numBallista,numRam,numCat,numScout, name){
    var marchId = 'm'+ (88888 + Math.floor(Math.random()*11111));
    var march = {};
    if (matTypeof(Seed.queue_atkinc)=='array')
      Seed.queue_atkinc = {};
    if (isFalse)
      march.marchType = 0;
    else if (isScout)
      march.marchType = 3;
    else
      march.marchType = 4;

    march.toCityId = Cities.cities[cityNum].id;
    if (isWild) {
      keys = unsafeWindow.Object.keys(Seed.wilderness['city'+Cities.cities[cityNum].id]);
      march.toTileId = Seed.wilderness['city'+Cities.cities[cityNum].id][keys[0]].tileId;
    } else {
      march.toTileId = Cities.cities[cityNum].tileId;
    }
    secs = parseInt(secs);
    march.arrivalTime = unixTime() + secs;
    march.departureTime = unixTime() - 10;
     march.unts = {}
  if(numScout != 0)
    march.unts.u3 = numScout
  if(numMilitia != 0)
    march.unts.u2 = numMilitia
  if(numSupply != 0)
  march.unts.u1 = numSupply
  if(numPike != 0)
  march.unts.u4 = numPike
  if(numSword != 0)
  march.unts.u5 = numSword
  if(numArcher != 0)
  march.unts.u6 = numArcher
  if(numCav != 0)
  march.unts.u7 = numCav
  if(numHeavy != 0)
  march.unts.u8 = numHeavy
   if(numWagon != 0)
   march.unts.u9 = numWagon
   if(numBallista != 0)
   march.unts.u10 = numBallista
  if(numRam != 0)
  march.unts.u11 = numRam
  if(numCat != 0)
  march.unts.u12 = numCat
    march.pid = 1234567
    march.score = 9
    march.mid = marchId.substr(1);
    march.players = {}
    march.players.u1234567 = {}
    march.players.u1234567.n = name;
    march.players.u1234567.t = 60
    march.players.u1234567.m = 5441192
    march.players.u1234567.s = 'M';
    march.players.u1234567.w = 1
    march.players.u1234567.a = 1
    march.players.u1234567.i = 5
    Seed.queue_atkinc[marchId] = march;
    Seed.players.u1234567 = march.players.u1234567;
  },

  clickFakeAttack : function (){
    var t = Tabs.F;
    var isScout = document.getElementById('fakeIsScout').checked;
    var isWild = document.getElementById('fakeIsWild').checked;
    var isFalse = document.getElementById('fakeFalse').checked;
    var secs = parseInt(document.getElementById('fakeSeconds').value);
    var mil = parseInt(document.getElementById('fakeMilitia').value);
  var numSupply = parseInt(document.getElementById('fakeSupply').value);
  var numPike = parseInt(document.getElementById('fakePike').value);
  var numSword = parseInt(document.getElementById('fakeSword').value);
  var numArcher = parseInt(document.getElementById('fakeArcher').value);
  var numCav = parseInt(document.getElementById('fakeCav').value);
  var numHeavy = parseInt(document.getElementById('fakeHeavy').value);
  var numWagon = parseInt(document.getElementById('fakeWagon').value);
  var numBallista = parseInt(document.getElementById('fakeBallista').value);
  var numRam = parseInt(document.getElementById('fakeRam').value);
  var numCat = parseInt(document.getElementById('fakeCat').value);
  var numScout = parseInt(document.getElementById('fakeScout').value);
  var name = document.getElementById('fakeName').value;
  var city = document.getElementById('fakeCity').value;
    t.createFakeAttack (city, isScout, isWild, isFalse, secs, mil, numSupply, numPike,numSword,numArcher,numCav,numHeavy,numWagon,numBallista,numRam,numCat,numScout,name);

  },
}

/*********************************** Fake TAB ***********************************/

Tabs.F = {
   tabLabel : 'F',
  tabOrder : 100,
  tabDisabled : !ENABLE_TEST_TAB,
  cont : null,

  init : function (div){
    var t = Tabs.F;
    t.cont = div;
  var citySelect = '   <SELECT id=fakeCity>';
      for (var c=0; c<Cities.numCities; c++) {
        aCity = Cities.cities[c].name + ' ('+Cities.cities[c].x + ','+ Cities.cities[c].y+')';
           citySelect += '<option value=\''+c+'\'>'+aCity+'</option>';
      }
      citySelect += '</select>';
    var m = '<TABLE><TR><TD align=right>Späh Angriff: </td><TD><INPUT type=checkbox id=fakeIsScout></td></tr>\
        <TR><TD align=right>Wildniss Angreifen: </td><TD><INPUT type=checkbox id=fakeIsWild></td></tr>\
        <TR><TD align=right>Fake Bericht: </td><TD><INPUT type=checkbox disabled id=fakeFalse></td></tr>\
        <TR><TD align=right>Sekunden: </td><TD><INPUT type=text size=4 value=300 id=fakeSeconds></td></tr>\
        <TR><TD align=right>Versorgungstruppe: </td><TD><INPUT type=text size=6 value=0 id=fakeSupply></td></tr>\
    <TR><TD align=right>Milizsoldat: </td><TD><INPUT type=text size=6 value=5000 id=fakeMilitia></td></tr>\
    <TR><TD align=right>Späher: </td><TD><INPUT type=text size=6 value=0 id=fakeScout></td></tr>\
      <TR><TD align=right>Lanzenträger: </td><TD><INPUT type=text size=6 value=0 id=fakePike></td></tr>\
      <TR><TD align=right>Schwertkämpfer: </td><TD><INPUT type=text size=6 value=0 id=fakeSword></td></tr>\
      <TR><TD align=right>Bogenschütze: </td><TD><INPUT type=text size=6 value=0 id=fakeArcher></td></tr>\
      <TR><TD align=right>Kavallerie: </td><TD><INPUT type=text size=6 value=0 id=fakeCav></td></tr>\
      <TR><TD align=right>Schwere Kavallerie: </td><TD><INPUT type=text size=6 value=0 id=fakeHeavy></td></tr>\
      <TR><TD align=right>Versorgungswagen: </td><TD><INPUT type=text size=6 value=0 id=fakeWagon></td></tr>\
      <TR><TD align=right>Ballisten: </td><TD><INPUT type=text size=6 value=0 id=fakeBallista></td></tr>\
      <TR><TD align=right>Rammbock: </td><TD><INPUT type=text size=6 value=0 id=fakeRam></td></tr>\
      <TR><TD align=right>Steinschleuder: </td><TD><INPUT type=text size=6 value=0 id=fakeCat></td></tr>\
      <TR><TD align=right>Fake Name: </td><TD><INPUT type=text size=13 value=FAKE_ANGRIFF id=fakeName></td></tr>\
      <TR><TD align=right>Ziel: </td><TD>'+citySelect+'</td></tr>\
        <TR><TD colspan=2 align=center><INPUT id=testSendMarch type=submit value="Fake Angriff" \></td></tr></table>\
        <INPUT id=ptReloadKOC type=submit value="Refresh KoC" \>\
        <BR><DIV id=testDiv style="background-color:#fffff0; maxwidth:675; max-height:430px; height:430px; overflow-y:auto;"></div>';
    t.cont.innerHTML = m;
    document.getElementById('testSendMarch').addEventListener ('click', t.clickFakeAttack, false);
    document.getElementById('ptReloadKOC').addEventListener ('click', t.reloadKOC, false);
    function xyNotify(city, x, y){
      var m = '[ Notified: '+ (city?city.name:'null') +', x='+ x +', y='+ y +' ]';
      document.getElementById('testNotify').innerHTML = m;
    }
  },

  hide : function (){
  },

  show : function (){
  },
  
  reloadKOC : function (){
    window.location.href = '';
    setTimeout (function (){window.location.href = window.location.href +'&rload=3';}, 0);
    var goto = 'http://apps.facebook.com/kingdomsofcamelot/?s='+getServerId();
    var t = '<FORM target="_top" action="'+ goto +'" method=post><INPUT id=xxButReload type=submit value=RELOAD><INPUT type=hidden name=s value="'+ getServerId() +'"</form>';
    var e = document.createElement ('div');
    e.innerHTML = t;
    document.body.appendChild (e);
    setTimeout (function (){document.getElementById('xxButReload').click();}, 0);
  },
  
  writeDiv : function (msg){
    var t = Tabs.F
    if (t.state != null)
      document.getElementById('testDiv').innerHTML = msg;
  },

  addDiv : function (msg){
    var t = Tabs.F;
    if (t.state != null)
      document.getElementById('testDiv').innerHTML += msg;
  },

  createFakeAttack : function (cityNum, isScout, isWild, isFalse, secs, numMilitia, numSupply, numPike,numSword,numArcher,numCav,numHeavy,numWagon,numBallista,numRam,numCat,numScout, name){
    var marchId = 'm'+ (88888 + Math.floor(Math.random()*11111));
    var march = {};
    if (matTypeof(Seed.queue_atkinc)=='array')
      Seed.queue_atkinc = {};
    if (isFalse)
      march.marchType = 0;
    else if (isScout)
      march.marchType = 3;
    else
      march.marchType = 4;

    march.toCityId = Cities.cities[cityNum].id;
    if (isWild) {
      keys = unsafeWindow.Object.keys(Seed.wilderness['city'+Cities.cities[cityNum].id]);
      march.toTileId = Seed.wilderness['city'+Cities.cities[cityNum].id][keys[0]].tileId;
    } else {
      march.toTileId = Cities.cities[cityNum].tileId;
    }
    secs = parseInt(secs);
    march.arrivalTime = unixTime() + secs;
    march.departureTime = unixTime() - 10;
     march.unts = {}
  if(numScout != 0)
    march.unts.u3 = numScout
  if(numMilitia != 0)
    march.unts.u2 = numMilitia
  if(numSupply != 0)
  march.unts.u1 = numSupply
  if(numPike != 0)
  march.unts.u4 = numPike
  if(numSword != 0)
  march.unts.u5 = numSword
  if(numArcher != 0)
  march.unts.u6 = numArcher
  if(numCav != 0)
  march.unts.u7 = numCav
  if(numHeavy != 0)
  march.unts.u8 = numHeavy
  if(numWagon != 0)
  march.unts.u9 = numWagon
  if(numBallista != 0)
  march.unts.u10 = numBallista
  if(numRam != 0)
  march.unts.u11 = numRam
  if(numCat != 0)
  march.unts.u12 = numCat
    march.pid = 1234567
    march.score = 9
    march.mid = marchId.substr(1);
    march.players = {}
    march.players.u1234567 = {}
    march.players.u1234567.n = name;
    march.players.u1234567.t = 60
    march.players.u1234567.m = 5441192
    march.players.u1234567.s = 'M';
    march.players.u1234567.w = 1
    march.players.u1234567.a = 1
    march.players.u1234567.i = 5
    Seed.queue_atkinc[marchId] = march;
    Seed.players.u1234567 = march.players.u1234567;
  },

  clickFakeAttack : function (){
    var t = Tabs.F;
    var isScout = document.getElementById('fakeIsScout').checked;
    var isWild = document.getElementById('fakeIsWild').checked;
    var isFalse = document.getElementById('fakeFalse').checked;
    var secs = parseInt(document.getElementById('fakeSeconds').value);
    var mil = parseInt(document.getElementById('fakeMilitia').value);
  var numSupply = parseInt(document.getElementById('fakeSupply').value);
  var numPike = parseInt(document.getElementById('fakePike').value);
  var numSword = parseInt(document.getElementById('fakeSword').value);
  var numArcher = parseInt(document.getElementById('fakeArcher').value);
  var numCav = parseInt(document.getElementById('fakeCav').value);
  var numHeavy = parseInt(document.getElementById('fakeHeavy').value);
  var numWagon = parseInt(document.getElementById('fakeWagon').value);
  var numBallista = parseInt(document.getElementById('fakeBallista').value);
  var numRam = parseInt(document.getElementById('fakeRam').value);
  var numCat = parseInt(document.getElementById('fakeCat').value);
  var numScout = parseInt(document.getElementById('fakeScout').value);
  var name = document.getElementById('fakeName').value;
  var city = document.getElementById('fakeCity').value;
    t.createFakeAttack (city, isScout, isWild, isFalse, secs, mil, numSupply, numPike,numSword,numArcher,numCav,numHeavy,numWagon,numBallista,numRam,numCat,numScout,name);

  },
}
/*********************************** Info tab ***********************************/

Tabs.Info = {
  tabOrder : 20,
  cont : null,

  init : function (div){
    var t = Tabs.Info;
    t.cont = div;
    fortmight = {
      u53: "4",
      u55: "7",
      u60: "1",
      u61: "2",
      u62: "3",
    };
    var t = Tabs.Info;
    rownum = 0;
    m = '<STYLE>.xtabH {background:#ffffe8; border:none; padding-right: 5px; padding-left: 5px; margin-left:10px; }\
            .xtabHL { background:#ffffe8; border-width: 1px; border-style: none none none solid; padding-right:5px; padding-left:5px; margin-left:10px; }\
            .xtabL { background:none; border-width: 1px; border-style: none none none solid; padding-right:5px; padding-left: 5px; margin-left:10px; }\
            .xtabLine { padding:0px; spacing:0px; height:1px; border-color:black; border-width: 1px; border-style: none none solid none }</style>\
        <DIV style="height:650px; max-height:650px; overflow-y:auto; overflow-x:hidden"><DIV class=ptstat>TRUPPEN INFORMATION</div><TABLE align=center cellpadding=1 cellspacing=0>\
        <TR align=center><TD class=xtab></td><TD class=xtabHL colspan=5><B>KOSTEN</b></td><TD class=xtabHL colspan=7><B>STATISTIK</b></td><TD class=xtabHL><B>VER.</b></td></tr>\
        <TR valign=bottom align=right><TD class=xtab></td><TD class=xtabHL>Futter</td><TD class=xtabH>Holz</td><TD class=xtabH>Stein</td>\
        <TD class=xtabH>Erz</td><TD class=xtabH>Volk</td><TD class=xtabHL>Macht</td><TD class=xtabH>Leb.</td><TD class=xtabH>Angr.</td><TD class=xtabH>Def.</td><TD class=xtabH>Gesch.</td><TD class=xtabH>Ent.</td><TD class=xtabH>Trag.</td>\
        <TD class=xtabHL>Futter</td></tr>\
        <TR style="height:1px;"><TD style="padding:0px; spacing:0px; height:1px; border-color:black; border-width: 1px; border-style: none none solid none" colspan=14></td></tr>';
    for (ui=1; ui<13; ui++){
      if (++rownum % 2)
        rsty = '';
      else
        rsty = ' style="background: #e8e8e8" ';
      cost = unsafeWindow.unitcost['unt'+ui];     //  NAME, Food, Wood, Stone, Ore, ?, IdlePop, Time
      stats = unsafeWindow.unitstats['unt'+ui];   //  Life, Attack, Defense, Speed, Range, Load
      food = unsafeWindow.unitupkeeps[ui];
      might = unsafeWindow.unitmight['u'+ui];
      m += '<TR '+ rsty +'align=right><TD class=xtab align=left><B>'+ cost[0] +'</b></td><TD class=xtabL>'+ cost[1] +'</td><TD class=xtab>'+ cost[2] +'</td>\
          <TD class=xtab>'+ cost[3] +'</td><TD class=xtab>'+ cost[4] +'</td><TD class=xtab>'+ cost[6] +'</td><TD class=xtabL>'+ might +'</td>\
          <TD class=xtab>'+ stats[0] +'</td><TD class=xtab>'+ stats[1] +'</td><TD class=xtab>'+ stats[2] +'</td><TD class=xtab>'+ stats[3] +'</td>\
          <TD class=xtab>'+ stats[4] +'</td><TD class=xtab>'+ stats[5] +'</td><TD class=xtabL>'+ food +'</td></tr>';

    }
    m += '<TR class=xtabLine><TD colspan=14 class=xtabLine></td></tr>';
    for (k in unsafeWindow.fortcost){
      if (++rownum % 2)
        rsty = '';
      else
        rsty = ' style="background: #e8e8e8" ';
      cost = unsafeWindow.fortcost[k];     //  NAME, Food, Wood, Stone, Ore, ?, IdlePop, Time
      fi = k.substring(3);
      stats = unsafeWindow.fortstats['unt'+fi];   //  Life, Attack, Defense, Speed, Range, Load
      food = 0;
      might = fortmight['u'+fi];
      name = cost[0].replace ('Defensive','');
      name = name.replace ('Wall-Mounted','');
      m += '<TR '+ rsty +'align=right><TD align=left class=xtab><B>'+ name +'</b></td><TD class=xtabL>'+ cost[1] +'</td><TD class=xtab>'+ cost[2] +'</td>\
          <TD class=xtab>'+ cost[3] +'</td><TD class=xtab>'+ cost[4] +'</td><TD class=xtab>'+ cost[6] +'</td><TD class=xtabL>'+ might +'</td>\
          <TD class=xtab>'+ stats[0] +'</td><TD class=xtab>'+ stats[1] +'</td><TD class=xtab>'+ stats[2] +'</td><TD class=xtab>'+ stats[3] +'</td>\
          <TD class=xtab>'+ stats[4] +'</td><TD class=xtab>'+ stats[5] +'</td><TD class=xtabL>'+ food +'</td></tr>';
    }
    m += '<TR class=xtabLine><TD colspan=14 class=xtabLine></td></tr>';
    m += '</table>';
  //Crest info
  var crestname = { 1101:'Bors',
          1102:'Ectors',
          1103:'Kays',
          1104:'Bediveres',
          1105:'Gawains',
          1106:'Percivals',
          1107:'Galahads',
          1108:'Lancelots',
          1109:'Arthurs',
          1110:'Morgana',
          1111:'Mordred',
          1112:'König Stag',
          1113:'Erdsiegel',
          1114:'Wassersiegel'};
  var crest = {};
  for (k in crestname){
    if(Seed.items['i'+k])
      crest[k] = Seed.items['i'+k];
    else
      crest[k] = 0;
  }
var crestreq = { 3:{1101:4, 1102:2, 1103:1},
         4:{1103:4, 1104:3, 1105:1},
         5:{1106:4, 1107:3, 1108:2},
         6:{1109:4, 1110:3, 1111:2},
         7:{1112:4, 1113:3, 1114:2}
        };
 
 m += '<DIV class=ptstat>WAPPEN INFORMATION</div><TABLE align=center cellpadding=1 cellspacing=0>\
      <TR CLASS="xtabH">\
        <TD class=xtab></TH>\
        <TD class=xtabHL><b>Vorraussetzung 1 (Vorhanden)</b></TD>\
        <TD class=xtabHL><b>Vorraussetzung 2 (Vorhanden)</b></TD>\
        <TD class=xtabHL><b>Vorraussetzung 3 (Vorhanden)</b></TD>\
      </TR>\
    <TR style="height:1px;"><TD style="padding:0px; spacing:0px; height:1px; border-color:black; border-width: 1px; border-style: none none solid none" colspan=14></td></tr>';
    rownum = 0;
    for(k in crestreq){
    if (++rownum % 2)
        rsty = '';
      else
        rsty = ' style="background: #e8e8e8" ';
    m += '<TR '+rsty+'>  \
      <TD class=xtab><B>Stadt '+k+'</B></TD>';
    for(u in crestreq[k])
      m+='<TD class=xtabL>'+crestreq[k][u]+' '+crestname[u]+ ' ('+crest[u]+') </TD>';
    m += '</TR>';
    }
 m += '</TABLE>';
  //End crest info
    //Link info
    m += '<DIV class=ptstat>NÜTZLICHE LINKS</div>';
    m += '<table width="700" border="0" cellspacing="0" cellpadding="0">';
    m += '<tr><td width="57"><b>Nr.</b></td>';
    m += '<td width="343"><b><center>Thema</center></b></td>';
    m += '<td width="156"><b><center>Quelle</center></b></td></tr>';
    m += '<tr><td><b># 1</b></td>';
    m += '<td><center><a href=http://www.kingdoms-of-camelot.de/archives/angriffe-auf-wildnisgebiete-strategie target=_blank>Angriffe auf Wildnisgebiete - Strategie</a></center></td>';
  m += '<td><center><a href=http://kingdoms-of-camelot.de target=_blank>kingdoms-of-camelot.de</a></center></td></tr>';
    m += '<tr><td><b># 2</b></td>';
    m += '<td><center><a href="http://www.kingdoms-of-camelot.de/archives/category/barbaren-lager" target="_blank">Angriffe auf Babaren Lager</a></center></td>';
    m += '<td><center><a href="http://kingdoms-of-camelot.de" target="_blank">kingdoms-of-camelot.de</a></center></td></tr>';
    m += '<tr><td><b># 3</b></td>';
    m += '<td><center><a href="http://koc.wikia.com/wiki/Crests" target="_blank">Wappen Suche</a></center></td>';
    m += '<td><center><a href="http://koc.wiki.com" target="_blank">koc.wiki.com</a></center></td></tr>';
    m += '<tr><td><b># 4</b></td>';
    m += '<td><center><a href="href=http://www.kingdoms-of-camelot.de/archives/category/wildnis" target="_blank">Wildniss Angriffe Allgemein</a></center></td>';
    m += '<td><center><a href="http://kingdoms-of-camelot.de" target="_blank">kingdoms-of-camelot.de</a></center></td></tr>';
  m += '<tr><td><b># 5</b></td>';
    m += '<td><center><a href="http://koc.god-like.org" target="_blank">KoC Scripts - Der erste Deutsche KoC Scripts Blog!</a></center></td>';
    m += '<td><center><a href="http://kocscripts.god-like.org" target="_blank">koc.god-like.org</a></center></td></tr>';
   m += '</table>';
  //End Link info
    m += '<DIV class=ptstat>ENTFERNUNGS RECHNER</div><DIV class=ptentry><TABLE align=center cellpadding=1 cellspacing=0>\
      <TR><TD class=xtab align=right><B>Startpunkt: </b></td><TD  class=xtab> X: <INPUT id=calcX type=text\> Y: <INPUT id=calcY type=text\> <SPAN id=ptloc1></span></td></tr>\
      <TR><TD class=xtab><B>Ziel: </b></td><TD class=xtab> X: <INPUT id=calcX2 type=text\> Y: <INPUT id=calcY2 type=text\> <SPAN id=ptloc2></span></td></tr></table>\
      <CENTER><DIV style="width:60%; font-size:14px; border: 1px solid; background-color:white; margin:20px 3px 3px 0px; padding:4px" id=ptdistout></div>\
  <div><br><b>Marschzeit für</b><br><select id="idETASelect">\
        <option value="0,250" > -- Auswählen -- </option>\
        <option value="0,180" > Versorgungstruppe </option>\
        <option value="0,200" > Milizsoldat </option>\
        <option value="0,3000" > Späher </option>\
        <option value="0,300" > Lanzenträger </option>\
        <option value="0,275" > Schwertkämpfer </option>\
        <option value="0,250" > Bogenschütze </option>\
        <option value="1,1000" > Kavallerie </option>\
        <option value="1,750" > Schwere Kavallerie </option>\
        <option value="1,150" > Versorgungswagen </option>\
        <option value="1,100" > Ballisten </option>\
        <option value="1,120" > Rammbock </option>\
        <option value="1,80" > Steinschleuder </option>\
</select><BR><BR><SPAN class=boldRed>(Startpunkt, Ziel und Truppen Auswählen!)</span></div>\
<DIV style="width:60%; font-size:14px; border: 1px solid; background-color:white; margin:20px 3px 3px 0px; padding:4px" id=ptETAout></div>\
ETA = <i>estimated time of arrival</i> | voraussichtliche Ankunftszeit</center></div>';
    m += '<DIV class=ptstat>PROVINZ KARTE</div><DIV id=ptProvMap style="height:'+ provMapCoords.imgHeight +'px; width:'+ provMapCoords.imgWidth +'px; background-repeat:no-repeat; background-image:url(\''+ URL_PROVINCE_MAP +'\')"></div>';

    m += '<DIV class=ptstat>WEITERE INFORMATIONEN</div>Kingdom of Camelot Client Version: '+ KOCversion +'<HR><a href="http://userscripts.org/scripts/show/98323" target="_blank">Power Tools - Deutsch</a> <BR>German Version by <a href="http://userscripts.org/users/297645/scripts" target="_blank">PDX</a> <BR>Version: <SPAN class=boldRed> '+ Version +' </span><BR> ';
    if (DEBUG_BUTTON)
      m += '<BR><INPUT id=ptButDebug type=submit name="SEED" value="DEBUG">';
    
    t.cont.innerHTML = m +'</div>';
   if (DEBUG_BUTTON)
      document.getElementById('ptButDebug').addEventListener('click', function (){debugWin.doit()}, false);
    new CdispCityPicker ('ptloc1', document.getElementById('ptloc1'), true, t.eventFromLocChanged, 0).bindToXYboxes(document.getElementById('calcX'), document.getElementById('calcY'));
    new CdispCityPicker ('ptloc2', document.getElementById('ptloc2'), true, t.eventLocChanged, 0).bindToXYboxes(document.getElementById('calcX2'), document.getElementById('calcY2'));
    //t.eventLocChanged(Cities.cities[0], Cities.cities[0].x, Cities.cities[0].y);      
    t.eventFromLocChanged(Cities.cities[0], Cities.cities[0].x, Cities.cities[0].y);
    document.getElementById('idETASelect').addEventListener ( 'change', t.eventLocChanged, false);    
    for (var c=0; c<Cities.numCities; c++)      
      t.makeCityImg (c, document.getElementById('ptProvMap'));
  },

  hide : function (){
  },

  show : function (){
  },

// var provMapCoords = {imgWidth:680, imgHeight:654, mapWidth:595, mapHeight:595, leftMargin:44, topMargin:39};  
  makeCityImg : function (cityNum, eMap){
    var t = Tabs.Info;
    var city = Cities.cities[cityNum];
//    var off = getAbsoluteOffsets (eMap);
    var x = parseInt((provMapCoords.mapWidth * city.x) / 750);
    var y = parseInt((provMapCoords.mapHeight * city.y) / 750);
    var ce = document.createElement ('div');
    ce.style.background = 'black';
    ce.style.opacity = '1.0';
    ce.style.position='relative';
    ce.style.display='block';
    ce.style.width='14px';
    ce.style.height='16px';
    ce.style.border='1px solid #fff';
    ce.style.color = 'white';
    ce.style.textAlign = 'center';
    ce.style.top = (y+provMapCoords.topMargin-(cityNum*16)-8) +'px';      
    ce.style.left = (x+provMapCoords.leftMargin-7) +'px';
    eMap.appendChild(ce);
    ce.innerHTML = (cityNum+1) +'';
  },
  eventLocChanged : function (city, x, y){
    var t = Tabs.Info;
    var x1 = parseInt(document.getElementById('calcX').value);
    var x2 = parseInt(document.getElementById('calcX2').value);
    if (isNaN(x2))
      return;
    var y1 = parseInt(document.getElementById('calcY').value);
    var y2 = parseInt(document.getElementById('calcY2').value);
    var m = 'Entfernung von '+ x1 +','+ y1 +' nach '+ x2 +','+ y2 +' ist: &nbsp;<B>'+ distance (x1, y1, x2, y2).toFixed(2) +'</b>';
    document.getElementById('ptdistout').innerHTML = m;
    var dist = distance (x1, y1, x2, y2);
    m = t.estETA(dist);
    if (m != null)
       document.getElementById('ptETAout').innerHTML = m;
    else logit("no M");
  },

  eventFromLocChanged : function (city, x, y){
    var t = Tabs.Info;
    t.ModelCity = city;
    var x1 = parseInt(document.getElementById('calcX').value);
    var x2 = parseInt(document.getElementById('calcX2').value);
    if (isNaN(x2))
      return;
    var y1 = parseInt(document.getElementById('calcY').value);
    var y2 = parseInt(document.getElementById('calcY2').value);
    var m = 'Entfernung von '+ x1 +','+ y1 +' nach '+ x2 +','+ y2 +' ist: &nbsp;<B>'+ distance (x1, y1, x2, y2).toFixed(2) +'</b>';
    document.getElementById('ptdistout').innerHTML = m;
    var dist = distance (x1, y1, x2, y2);
    m = t.estETA(dist);
    if (m != null)
       document.getElementById('ptETAout').innerHTML = m;
    else logit("no M");
  },

  estETA : function(dist) { // Need Relief Station Levels to estimate transport, reinf, or reassign times.
    var t = Tabs.Info;
    var cityID;
    if (dist == 0) return "Keine Marschzeit gefunden!";
    var EtaType = document.getElementById('idETASelect');
    var baseSpeedSel = EtaType.options[EtaType.selectedIndex].value;
    var m = baseSpeedSel.split(',');
    var horse = parseInt(m[0]);
    var baseSpeed = parseInt(m[1]);
    if (baseSpeed == 0) return "ETA: unbekannt";
    var mmLvl = parseInt(Seed.tech.tch11);//Magical Mapping
    var Speed = 0;
    if (horse){
    //HorsesSiegeSpeed = Base * (1 + MM/10) * (1 + AH/20)
      var hsLvl = parseInt(Seed.tech.tch12);//Alloy Horse Shoes
      Speed = baseSpeed * (1 + mmLvl/10) * (1 + hsLvl/20);
    }
    else {
    //FootSpeed = Base * (1 + MM/10)
      Speed = baseSpeed * (1 + mmLvl/10);
    }
    //Grid Speed (tiles/second) = Speed (100ths/min) / 6000
    var gSpeed = 0;
    var estSec = 0;
    if (Speed>0) {
      gSpeed = Speed/6000;
      estSec = (dist/gSpeed).toFixed(0);
    }
    var ETAstr = 'Angriff:  <B>' + timestr ((parseInt((estSec+''))+30)+'',1) +'</b>';
    //RS - Cities Relief Station Level
    //Friendly Speed = Speed * (1 + RS/2)
    if (t.ModelCity) {
      cityID = t.ModelCity.id;
      //logit ('ETAest - cityID: ' + cityID);
      var building = getCityBuilding (cityID, 18);
      if (building) {
        //logit ('ETAest - building: ' + building.count + ' : ' + building.maxLevel);
        fSpeed = Speed * (1 + parseInt(building.maxLevel)/2);
        gSpeed = fSpeed/6000;
        estSec = (dist/gSpeed).toFixed(0);
        var friendTimestr = '| Verbündet: <B>' + timestr ((parseInt((estSec+''))+30)) +'</b>';
        ETAstr = ETAstr + ' ' + friendTimestr;
      }
    }
    return ETAstr;
  },
}

/*********************************** Options Tab ***********************************/

Tabs.Options = {
  tabLabel : 'Einstellung',
  tabOrder : 45,
  cont : null,
  fixAvailable : {},

  init : function (div){
    var t = Tabs.Options;
    t.cont = div;
    
    try {      
      m = '<TABLE class=ptTab>\
       <TR><TD colspan=2><B><u>Power Tools - Einstellung</u></b></td></tr>\
        <TR><TD><INPUT id=ptAllowWinMove type=checkbox /></td><TD>Fenster verschieben erlauben.</td></tr>\
        <TR><TD><INPUT id=ptHideOnGoto type=checkbox /></td><TD>Automatisch bei Klick auf Koordinaten Fenster Schließen.</td></tr>\
        <TR><TD><INPUT id=ptEnableFoodWarn type=checkbox /></td><TD>\'Reicht für\' in Rot Anzeigen wenn es noch für \
        <INPUT id=optFoodHours type=text size=3 value="'+ Options.foodWarnHours +'"> Stunden ausreicht! <SPAN class=boldRed>(Stats Tab)</span></td></tr>\
    <TR><TD><INPUT id=ptEnableFoodAlert type=checkbox /></td><TD>Im Allianz Chat posten wenn die Nahrung noch für \
    <INPUT id=optFoodAlertHours type=text size=3 value="'+ Options.foodAlertHours +'"> Stunden ausreicht! <SPAN class=boldRed>(Bei Refresh und alle 15 Min.)</span></td></tr>\
  <TR><TD colspan=2><P><B><u>Chat - Einstellung</u></b></td></tr>\
  <TR><TD><INPUT id=togChatStuff type=checkbox /></td><TD>Chat Erweitern <SPAN class=boldRed>(Koordianten Klickbar, Avatar klicken zum flüstern)</span> </td></tr>\
        <TR><TD><INPUT id=togChatGlobal type=checkbox /></td><TD>Chat Hintergrundfarbe Hinzufügen!</td></tr>\
  <TR><TD><INPUT id=togChatWhisper type=checkbox /></td><TD>Flüster Text <SPAN class=boldRed>Rot</span> anzeigen!</td></tr>\
  <TR><TD><INPUT id=togChatBold type=checkbox /></td><TD>Alles mit Fetter Schrift im Chat anzeigen!</td></tr>\
        <TR><TD colspan=2><P><B><u>Kingdom of Camelot - Einstellung</u></b></td></tr>\
        <TR><TD><INPUT id=togMsgCountFix type=checkbox /></td><TD>Zeige die Anzahl der Berichte und Nachrichten getrennt an.</td></tr>';
      m += '<TR><TD><INPUT id=togAllRpts type=checkbox /></td><TD>Erweiterte Allianz Berichte.</td></tr>\
        <TR><TD><INPUT id=togAllowAlter type=checkbox /></td><TD>Erlaube anderen Scripten das Format der Allianz Berichte zu wechseln.</td></tr>\
        <TR><TD><INPUT id=togEnhanceMsging type=checkbox /></td><TD>Erweiterte Nachrichten. <SPAN class=boldRed>("Weiterleiten" und "Alle Offiziere" Buttons)</span></td></tr>\
        <TR><TD><INPUT id=togPageNav type=checkbox /></td><TD>Erweiterte Seiten Navigation <SPAN class=boldRed>(Nachrichten und Berichte)</span> </td></tr>\
        <TR><TD><INPUT id=togWarnZero type=checkbox /></td><TD>Warnen falls du nach 0,0 Maschieren möchtest.</td></tr>\
        <TR><TD><INPUT id=togGmtClock type=checkbox /></td><TD>GMT Uhrzeit neben der Camelot Zeit <SPAN class=boldRed>(Um Angriffe zu planen)</span> </td></tr>\
        <TR><TD><INPUT id=togAttackPicker type=checkbox /></td><TD>Heiligtum Auswähler auf der Truppen Bewegungs Seite Anzeigen. <SPAN class=boldRed>(Verstärkung, Transport etc...)</span></td></tr>\
        <TR><TD><INPUT id=togBatRounds type=checkbox /></td><TD>Die Runden Anzahl einblenden</td></tr>\
        <TR><TD><INPUT id=togAtkDelete type=checkbox /></td><TD>Berichte Lösch Button einblenden <SPAN class=boldRed>(Um die Berichten zu Löschen)</span></td></tr>\
        <TR><TD colspan=2><BR><BR><B><u>Bug Fix</u></b></td></tr>\
        <TR><TD><INPUT id=togTowerFix type=checkbox /></td><TD>Wachturm Berichte Fix <SPAN class=boldRed>(Stadt, Wildnis oder Ungültig)</span></td></tr>\
        <TR><TD><INPUT id=togMapDistFix type=checkbox /></td><TD>Zeige die Entfernung von der Ausgewählten Stadt, und nicht immer die von der ersten!</td></tr>\
        <TR><TD><INPUT id=togTowerFix2 type=checkbox /></td><TD>Fake Angriffe durch Späher Attacken vermeiden.</td></tr>\
        <TR><TD><INPUT id=togKnightSelect type=checkbox /></td><TD><u>Keinen</u> Ritter auswählen wenn der Marsch typ: <SPAN class=boldRed>Spähen, Transport</span> oder <SPAN class=boldRed>Verstärken</span> ist!</td></tr>\
        <TR><TD><INPUT id=togCoordBox type=checkbox /></td><TD>Koordinaten Box  <SPAN class=boldRed>über</span> der Truppenbewegung Anzeigen!</td></tr>\
        </table><BR><BR><HR><u>Hinweis</u>: Wenn eine Box nicht klickbar ist hat KoC mal wieder eine änderung vorgenommen!<HR><BR><a href="http://userscripts.org/scripts/show/98323" target="_blank">Power Tools - Deutsch</a> - German Version by <a href="http://userscripts.org/users/297645/scripts" target="_blank">PDX</a> - Version: <SPAN class=boldRed> '+ Version +' </span>';
      t.cont.innerHTML = m;
      
      t.togOpt ('ptEnableFoodWarn', 'enableFoodWarn');
    t.togOpt ('ptEnableFoodAlert', 'enableFoodAlert');
      t.togOpt ('ptHideOnGoto', 'hideOnGoto');
      t.togOpt ('ptAllowWinMove', 'ptWinDrag', mainPop.setEnableDrag);
      t.togOpt ('togAllowAlter', 'allowAlterAR');
      t.togOpt ('togTowerFix', 'fixTower', TowerAlerts.enableFixTarget, TowerAlerts.isFixTargetAvailable);
      t.togOpt ('togTowerFix2', 'fixTower2', TowerAlerts.enableFixFalseReports, TowerAlerts.isFixFalseReportsAvailable);
      t.togOpt ('togMsgCountFix', 'fixMsgCount', MessageCounts.enable, MessageCounts.isAvailable);
      t.togOpt ('togMapDistFix', 'fixMapDistance', MapDistanceFix.enable, MapDistanceFix.isAvailable);
      t.togOpt ('togWarnZero', 'fixWarnZero', WarnZeroAttack.setEnable, WarnZeroAttack.isAvailable);
      t.togOpt ('togPageNav', 'fixPageNav', PageNavigator.enable, PageNavigator.isAvailable);
      t.togOpt ('togGmtClock', 'gmtClock', GMTclock.setEnable);
      t.togOpt ('togChatStuff', 'chatEnhance', ChatStuff.setEnable, ChatStuff.isAvailable);
   t.togOpt ('togChatWhisper', 'chatwhisper');
    t.togOpt ('togChatGlobal', 'chatglobal');
      t.togOpt ('togChatBold', 'chatbold');  
      t.togOpt ('togKnightSelect', 'fixKnightSelect', AttackDialog.setEnable, AttackDialog.isKnightSelectAvailable);
      t.togOpt ('togAttackPicker', 'attackCityPicker', AttackDialog.setEnable, AttackDialog.isCityPickerAvailable);
      t.togOpt ('togEnhanceMsging', 'enhanceMsging', messageNav.setEnable, messageNav.isAvailable);
      t.togOpt ('togCoordBox', 'mapCoordsTop', CoordBox.setEnable, CoordBox.isAvailable);
      t.togOpt ('togBatRounds', 'dispBattleRounds', null, battleReports.isRoundsAvailable);
      t.togOpt ('togAtkDelete', 'reportDeleteButton', null, battleReports.isDeleteAvailable);
                  
      document.getElementById('optFoodHours').addEventListener ('change', function () {
          var x = document.getElementById('optFoodHours').value;
          if (isNaN(x) || x<0.01 || x>99999){
            document.getElementById('optFoodHours').value = Options.foodWarnHours;
            return;
          }
          Options.foodWarnHours = x;
          saveOptions();
        }, false);
    document.getElementById('optFoodAlertHours').addEventListener ('change', function () {
          var x = document.getElementById('optFoodAlertHours').value;
          if (isNaN(x) || x<0.01 || x>99999){
            document.getElementById('optFoodAlertHours').value = Options.foodAlertHours;
            return;
          }
          Options.foodAlertHours = x;
          saveOptions();
        }, false);
      var checkbox = document.getElementById('togAllRpts');
       if (Options.enhanceARpts)
         checkbox.checked = true;
       checkbox.addEventListener ('change', function() {Options.enhanceARpts=document.getElementById('togAllRpts').checked; saveOptions(); AllianceReports.enable(Options.enhanceARpts);}, false);
      
    } catch (e) {
      t.cont.innerHTML = '<PRE>'+ e.name +' : '+ e.message +'</pre>';  
    }
  },
  hide : function (){
  },

  show : function (){
  },
  togOpt : function (checkboxId, optionName, callEnable, callIsAvailable){
    var t = Tabs.Options;
    var checkbox = document.getElementById(checkboxId);
    
    if (callIsAvailable && callIsAvailable()==false){
      checkbox.disabled = true;
      return;
    }
    if (Options[optionName])
      checkbox.checked = true;
    checkbox.addEventListener ('change', new eventToggle(checkboxId, optionName, callEnable).handler, false);
    function eventToggle (checkboxId, optionName, callOnChange){
      this.handler = handler;
      var optName = optionName;
      var callback = callOnChange;
      function handler(event){
        Options[optionName] = this.checked;
        saveOptions();
        if (callback != null)
          callback (this.checked);
      }
    }
  },
}
/********************************* Search Tab *************************************/

function distance (d, f, c, e) {
  var a = 750;
  var g = a / 2;
  var b = Math.abs(c - d);
  if (b > g)
    b = a - b;
  var h = Math.abs(e - f);
  if (h > g)
    h = a - h;
  return Math.round(100 * Math.sqrt(b * b + h * h)) / 100;
};

Tabs.Search = {
  tabLabel : ' Suchen',
  tabOrder : 10,
  tabDisabled : !ENABLE_SEARCH_TAB,
  //MapAjax : new CMapAjax(),
  cont:null,

  init : function (div){
    var t = Tabs.Search;
  var Provinces = {1:{'name':"Tintagel",'x':75,'y':75},
        2:{'name':"Cornwall",'x':225,'y':75},
        3:{'name':"Astolat",'x':375,'y':75},
        4:{'name':"Lyonesse",'x':525,'y':75},
        5:{'name':"Corbenic",'x':625,'y':75},

        6:{'name':"Paimpont",'x':75,'y':225},
        7:{'name':"Cameliard",'x':225,'y':225},
        8:{'name':"Sarras",'x':375,'y':225},
        9:{'name':"Canoel",'x':525,'y':225},
        10:{'name':"Avalon",'x':625,'y':225},

        11:{'name':"Carmathen",'x':75,'y':375},
        12:{'name':"Shallot",'x':225,'y':375},
        13:{'name':"-------",'x':375,'y':375},
        14:{'name':"Cadbury",'x':525,'y':375},
        15:{'name':"Glastonbury",'x':625,'y':375},

        16:{'name':"Camlamn",'x':75,'y':525},
        17:{'name':"Orkney",'x':225,'y':525},
        18:{'name':"Dore",'x':375,'y':525},
        19:{'name':"Logres",'x':525,'y':525},
        20:{'name':"Caerleon",'x':625,'y':525},

        21:{'name':"Parmenie",'x':75,'y':675},
        22:{'name':"Bodmin Moor",'x':225,'y':675},
        23:{'name':"Cellwig",'x':375,'y':675},
        24:{'name':"Listeneise",'x':525,'y':675},
        25:{'name':"Albion",'x':625,'y':675}};
  unsafeWindow.PTgotoMap2 = t.gotoMap;
    unsafeWindow.PTpd = t.clickedPlayerDetail;
    unsafeWindow.PTpd2 = t.clickedPlayerLeaderboard;
  unsafeWindow.PCpo2 = t.clickedPlayerCheckOnline;
    unsafeWindow.PCplo2 = t.clickedPlayerGetLastLogin;
    t.cont = div;
    t.cont.innerHTML = '\
      <DIV class=ptentry><table><tr><td><TABLE><TR valign=bottom><TD class=xtab width=100 align=right>Suchen: </td><TD>\
      <SELECT id="srcType">\
        <OPTION value=0>Barbaren Lager</option>\
        <OPTION value=1>Wildniss</option>\
    <OPTION value=2>Städte</option>\
      </select></td></tr>\
      </table>\
      <DIV id="srcOpts" style="height:100px"></div></td><td style="visibility:hidden"><DIV id=divOutOpts style="background:#e0e0f0; padding:10px ;visibility:hidden"></div></td></tr></table></div>\
      <DIV id="srcResults" style="height:470px; max-height:470px;"></div>';
    var psearch = document.getElementById ("srcType");
    m = '<TABLE><TR valign=middle><TD class=xtab width=100 align=right>Startpunkt: &nbsp; X: </td><TD class=xtab>\
      <INPUT id=srchX type=text\> &nbsp; Y: <INPUT id=srchY type=text\> &nbsp;';
  m += '<span><select id="ptprovinceXY"><option>--Provinzen--</option>';
    for (var i in Provinces) {
      m += '<option value="'+i+'">'+Provinces[i].name+'</option>';
    }
  m += '</select></span>';

  m += '</td></tr><TR><TD class=xtab align=right>Max. Entfernung: </td><TD class=xtab><INPUT id=srcDist size=4 value=10 /> &nbsp; <SPAN id=spInXY></span></td></tr>';
    m += '<TR><TD class=xtab></td><TD class=xtab><INPUT id=srcStart type=submit value="Suche Starten"/></td></tr>';
    m += '</table>';
    document.getElementById ('srcOpts').innerHTML = m;
    new CdispCityPicker ('srchdcp', document.getElementById('spInXY'), true, null, 0).bindToXYboxes(document.getElementById ('srchX'), document.getElementById ('srchY'));
    document.getElementById ('ptprovinceXY').addEventListener('change', function() {
    if (this.value >= 1) {
      document.getElementById ('srchX').value = Provinces[this.value].x;
      document.getElementById ('srchY').value = Provinces[this.value].y;
      document.getElementById ('srcDist').value = 75;
    }
    }, false);
  document.getElementById ('srcStart').addEventListener ('click', t.clickedSearch, false);
  },

//Edit add city search
clickedPlayerDetail : function (span, uid){
    var t = Tabs.AllianceList;
    span.onclick = '';
    span.innerHTML = "suche details ...";
    t.fetchPlayerInfo (uid, function (r) {t.gotPlayerDetail(r, span)});
  },

  clickedPlayerLeaderboard : function (span, uid){
    var t = Tabs.AllianceList;
    span.onclick = '';
    span.innerHTML = "suche leaderboard info ...";
    t.fetchLeaderboard (uid, function (r) {t.gotPlayerLeaderboard(r, span)});
  },
  
  clickedPlayerCheckOnline : function (span, uid){
  var s = Tabs.Search;
    span.onclick = '';
    span.innerHTML = "suche online status ...";
    s.fetchPlayerStatus (uid, function (r) {s.gotPlayerStatus(r, span, uid)});
  },
  
  fetchPlayerStatus : function (uidArray, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.checkArr = uidArray;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/getOnline.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        notify (rslt);
      },
      onFailure: function (rslt) {
        notify ({errorMsg:'AJAX error'});
      },
    });
  },


  
  gotPlayerLeaderboard : function (rslt, span){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      span.innerHTML = rslt.errorMsg;
      return;
    }
    if (rslt.totalResults == 0){
      span.innerHTML = '<B>Leaderboard:</b> nicht gefunden! evtl. im Nebel ?';
      return;
    }
    var p = rslt.results[0];
    var an = p.allianceName;
    if (!an || an=='' || p.officerType==4)
      an = 'none';
    else
      an += ' ('+ officerId2String(p.officerType) +')';
    m = '<TABLE cellspacing=0 class=ptTab><TR><TD><B>Leaderboard: </b></td><TD colspan=2> Macht: '+ p.might  +' &nbsp; Allianz: '+ an +'</td></tr>';
    for (var i=0; i<p.cities.length; i++){
      var c = p.cities[i];
      m += '<TR><TD align=right><B>Stadt #'+ (i+1) +':</b></td><TD> &nbsp; '+ c.cityName +' '+coordLink (c.xCoord, c.yCoord)+'</td><TD width=75%> &nbsp; Level: '
        + c.tileLevel +' &nbsp; &nbsp; Status: '+ cityStatusString (c.cityStatus) +' &nbsp; &nbsp; Erstellt: ' + c.dateCreated.substr(0,10) +'</td></tr>';
    }  
    span.innerHTML = m + '</table>';
  },
    
  gotPlayerDetail : function (rslt, span){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      span.innerHTML = rslt.errorMsg;
      return;
    }
    var u = rslt.userInfo[0];
    var a = 'None';
    if (u.allianceName)
      a = u.allianceName +' ('+ getDiplomacy(u.allianceId) + ')';
    var m = '<TABLE cellspacing=0 class=ptTab><TR><TD><B>Details:</b> &nbsp; </td><TD>Allianz: '+ a +' &nbsp; Städte: '
          + u.cities +' &nbsp; Bevölkerung: '+ u.population +'</td></tr><TR><TD></td><TD>Provinzen: ';
    var pids = u.provinceIds.split (',');
    var p = [];
    for (var i=0; i<pids.length; i++)
      p.push(unsafeWindow.provincenames['p'+pids[i]]);
    span.innerHTML = m + p.join (', ') +'</td></tr></table>';
  },
  
  gotPlayerStatus : function (rslt, span,uid){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      span.innerHTML = rslt.errorMsg;
      return;
    }

    var p = rslt.data;
    if (p[uid] == true) {
      m = '<span style="color:green"><blink><b>Online</b></blink></span>';
    } else {
       m = '<span style="color:red"><b>evtl. Offline</b></span>';
    }  
    span.innerHTML = m + '';
  },

  gotPlayerLastLogin : function (rslt, span){
    var t = Tabs.AllianceList;
    if (!rslt.ok){
      span.innerHTML = rslt.errorMsg;
      return;
    }

    var p = rslt.playerInfo;
    var lastLogin = rslt.playerInfo.lastLogin;
    
    if (lastLogin) {
      m = '<span style="color:black">Letzter Login: '+lastLogin+'</span>';
    } else {
       m = '<span style="color:red">Keine Logindaten gefunden: '+lastLogin+'</span>';
    }  
    span.innerHTML = m + '';
  },
//End edit city search

  hide : function (){
  },

  show : function (cont){
  },

  opt : {},

  searchRunning : false,
  tilesSearched : 0,
  tilesFound : 0,
  curX : 0,
  curY : 0,
  lastX : 0,
  firstX : 0,
  firstY : 0,
  lastY : 0,

  normalizeCoord : function (x){
    if ( x >= 750)
      x -= 750;
    else if (x < 0)
      x += 750;
    return parseInt (x/5) * 5;
  },

  clickedSearch : function (){
    var t = Tabs.Search;

    if (t.searchRunning){
      t.stopSearch ('SUCHE ABGEBROCHEN!');
      return;
    }
    t.opt.searchType = document.getElementById ('srcType').value;
    t.opt.startX = parseInt(document.getElementById ('srchX').value);
    t.opt.startY = parseInt(document.getElementById ('srchY').value);
    t.opt.maxDistance = parseInt(document.getElementById ('srcDist').value);
    errMsg = '';

    if (isNaN (t.opt.startX) ||t.opt.startX<0 || t.opt.startX>749)
      errMsg = "<blink>X muss zwischen 0 und 749 liegen!</blink><BR>";
    if (isNaN (t.opt.startY) ||t.opt.startY<0 || t.opt.startY>749)
      errMsg += "<blink>Y muss zwischen 0 und 749 liegen!</blink><BR>";
    if (isNaN (t.opt.maxDistance) ||t.opt.maxDistance<1 || t.opt.maxDistance>750)
      errMsg += "<blink>Max. Entfernung muss zwischen 1 und 750 liegen!</blink><BR>";
    if (errMsg != ''){
      document.getElementById('srcResults').innerHTML = '<FONT COLOR=#660000>FEHLER:</font><BR><BR>'+ errMsg;
      return;
    }

    t.searchRunning = true;
    document.getElementById ('srcStart').value = 'Suche Abbrechen';
    m = '<DIV class=ptstat><TABLE width=100% cellspacing=0><TR><TD class=xtab width=125><DIV id=statSearched></div></td>\
        <TD class=xtab align=center><SPAN id=statStatus></span></td>\
        <TD class=xtab align=right width=125><DIV id=statFound></div></td></tr></table></div>\
      <TABLE width=100%><TR><TD><DIV id=divOutTab style="width:100%; height:470px; max-height:470px; overflow-y:auto;"></div></td></tr></table>';
    document.getElementById('srcResults').innerHTML = m;
    if (t.opt.searchType == 0)
      typeName = 'Barbaren Lager';
    else if (t.opt.searchType == 1)
      typeName = 'Wildnisse';
  else
    typeName = 'Städte';

    m = '<CENTER><B>Suche nach '+ typeName +'<BR>\
        Startpunkt: '+ t.opt.startX +','+ t.opt.startY +'  &nbsp; Entfernung: '+ t.opt.maxDistance +'<BR></center>\
        <DIV class=ptentry><TABLE cellspacing=0 width=100%><TR align=center><TD class=xtab colspan=10><B>EINSTELLUNG:</b><BR></td></tr>';
  if (t.opt.searchType == 1 || t.opt.searchType == 0) {
      m += '<TR><TD class=xtab align=right>Min. Level:</td><TD class=xtab> <INPUT id=filMinLvl size=2 value='+ Options.srcMinLevel +' /></td></tr>\
        <TR><TD class=xtab align=right>Max. Level:</td><TD class=xtab> <INPUT id=filMaxLvl size=2 value='+ Options.srcMaxLevel +' /></td></tr>';
  }
    if (t.opt.searchType == 1){
      m += '<TR><TD class=xtab align=right>Wildniss Typ:</td><TD class=xtab><SELECT id=filWildType>';
      m += htmlOptions ( {1:'Glassland/See', 3:'Wälder', 4:'Hügel', 5:'Berg', 6:'Ebene', 0:'Alle'}, Options.wildType );
      m += '</select></td></tr><TR><TD class=xtab align=right>Frei:</td>\
      <TD class=xtab><INPUT id=filUnowned type=CHECKBOX '+ (Options.unownedOnly?' CHECKED':'') +'\><td></tr>';
    }
  if (t.opt.searchType == 1 || t.opt.searchType == 0) {
    m += '<TR><TD class=xtab align=right>Sortieren:</td><TD class=xtab><SELECT id=filSortBy>\
        <OPTION value="Level" '+ (Options.srcSortBy=='Level'?'SELECTED':'')  +'>Level</option>\
        <OPTION value="Entfernung" '+ (Options.srcSortBy=='Entfernung'?'SELECTED':'')  +'>Entfernung</option>';
    if(t.opt.searchType == 1){ m+= '<OPTION value="Macht" '+ (Options.srcSortBy=='Macht'?'SELECTED':'')  +'>Macht</option>';}
      m += '</select></td></tr>\
            <TR><TD class=xtab align=right>Nur Koordinaten: </td><TD class=xtab><INPUT type=checkbox id=coordsOnly \></td></tr>\
            </table></div><BR><SPAN id=srchSizeWarn></span>';
  } else {
   m += '<TR><TD class=xtab align=right>Stadt Typ:</td><TD class=xtab><SELECT id=filCities>';
     m += htmlOptions ( {1:'Alle', 2:'Alliierte', 3:'Freundlich', 4:'Feinlich', 5:'Neutral', 6:'Allianzlos', 7:'Nebel'}, Options.cityType );
     m += '</select></td></tr>';    
   m += '<TR><TD class=xtab align=right>Sortieren:</td><TD class=xtab><SELECT id=filSortBy>\
      <OPTION value="Macht" '+ (Options.srcSortBy=='Macht'?'SELECTED':'')  +'>Macht</option>\
      <OPTION value="Entfernung" '+ (Options.srcSortBy=='Entfernung'?'SELECTED':'')  +'>Entfernung</option>\
           </select></td></tr>\
       <TR><TD class=xtab align=right>Min. Macht:</td><TD class=xtab><INPUT type=text id=minMight value='+Options.MightSrc+' size=3 \></td></tr>\
           <TR><TD class=xtab align=right>Nur Koordinaten:</td><TD class=xtab><INPUT type=checkbox id=coordsOnly \></td></tr>\
           </table></div><BR><SPAN id=srchSizeWarn></span>';
  }

  document.getElementById ('divOutOpts').style.visibility = 'visible';
    document.getElementById('divOutOpts').innerHTML = m;
  if (t.opt.searchType == 1 || t.opt.searchType == 0) {
    document.getElementById('filMinLvl').addEventListener ('change', function (){
      Options.srcMinLevel = document.getElementById('filMinLvl').value;
      saveOptions();
      t.dispMapTable ();
      }, false);
    document.getElementById('filMaxLvl').addEventListener ('change', function (){
      Options.srcMaxLevel = document.getElementById('filMaxLvl').value;
      saveOptions();
      t.dispMapTable ();
      }, false);
  }
    document.getElementById('filSortBy').addEventListener ('change', function (){
      Options.srcSortBy = document.getElementById('filSortBy').value;
      saveOptions();
      t.dispMapTable ();
      }, false);
    document.getElementById('coordsOnly').addEventListener ('change', function (){ t.dispMapTable (); }, false);
    if (t.opt.searchType == 1){
      document.getElementById('filWildType').addEventListener ('change', function (){
        Options.wildType = document.getElementById('filWildType').value;
        saveOptions();
        t.dispMapTable ();
        }, false);
      document.getElementById('filUnowned').addEventListener ('change', function (){
        Options.unownedOnly = (document.getElementById('filUnowned').checked);
        saveOptions();
        t.dispMapTable ();
        }, false);
    }
  if (t.opt.searchType == 2){
    document.getElementById('filCities').addEventListener ('change', function (){
    Options.cityType = document.getElementById('filCities').value
    saveOptions();
        t.dispMapTable ();
    },false);
    document.getElementById('minMight').addEventListener ('change', function (){
    Options.MightSrc = document.getElementById('minMight').value
    saveOptions();
        t.dispMapTable ();
    },false);
  }

    t.mapDat = [];
    t.firstX =  t.opt.startX - t.opt.maxDistance;
    t.lastX = t.opt.startX + t.opt.maxDistance;
    t.firstY =  t.opt.startY - t.opt.maxDistance;
    t.lastY = t.opt.startY + t.opt.maxDistance;
    t.tilesSearched = 0;
    t.tilesFound = 0;
    t.curX = t.firstX;
    t.curY = t.firstY;
    var xxx = t.normalizeCoord(t.curX);
    var yyy = t.normalizeCoord(t.curY);
    document.getElementById ('statStatus').innerHTML = 'Durchsuche... '+ xxx +','+ yyy;
if (DEBUG_TRACE) logit (" 0 clickedSearch()... setTimeout ..:" + xxx +' , '+ yyy +' , '+ t.mapCallback.name);
    setTimeout (function(){Map.request (xxx, yyy, 15, t.mapCallback)}, MAP_DELAY);
  },

  dispMapTable : function (){
    var tileNames = ['Barbaren Lager', 'Grassland', 'See', 'Wälder', 'Hügel', 'Berg', 'Ebene', 'Stadt' ];
    var t = Tabs.Search;
    var coordsOnly = document.getElementById('coordsOnly').checked;
if (DEBUG_TRACE) DebugTimer.start();
    function mySort(a, b){
      if (Options.srcSortBy == 'Level'){
        if ((x = a[4] - b[4]) != 0)
          return x;
      }
    if (Options.srcSortBy == 'Macht'){
    if(b[10] == null) b[10] = 0;
    if(a[10] == null) a[10] = 0;
        if ((x = b[10] - a[10]) != 0)
          return x;
      }
      return a[2] - b[2];
    }

   dat = [];
    for (i=0; i<t.mapDat.length; i++){
      lvl = parseInt (t.mapDat[i][4]);
      type = t.mapDat[i][3];
    if (t.opt.searchType == 2 && type == 7 ) {
if (DEBUG_TRACE) DebugTimer.display('if (t.opt.searchType == 2 && type == 7 )  document.getElementById( idSrchFilter ).value = ' + document.getElementById('idSrchFilter').value + ' ' + t.mapDat[i][12]);
              switch(parseInt (document.getElementById('idSrchFilter').value)) {
                case 0:
                 dat.push(t.mapDat[i]);
                 break;
                case 1:
                   if (t.mapDat[i][12] == 'Feindlich') dat.push(t.mapDat[i]);
                   break;
                case 2:
                   if (t.mapDat[i][5]===true) dat.push(t.mapDat[i]);
                   break;
                case 3:
                   if (t.mapDat[i][12] == 'Alliierte') dat.push(t.mapDat[i]);
                   break;
                case 4:
                   if (t.mapDat[i][12] == 'Freundlich') dat.push(t.mapDat[i]);
                   break;
                case 5:
                   if (t.mapDat[i][12] == 'Neutral') dat.push(t.mapDat[i]);
                   break;
                 case 6:
                   if (t.mapDat[i][12] == 'Allianzlos') dat.push(t.mapDat[i]);
                   break;
             }
    } else {
       if (lvl>=Options.srcMinLevel && lvl<=Options.srcMaxLevel){
        if (t.opt.searchType==0
            || (Options.woodWild==1 && type == 3)
            || (Options.hillWild==1 && type ==4)
            || (Options.mtnWild==1 && type==5)
            || (Options.plnWild==1 && type == 6)
            || (Options.foodWild==1 && (type==1 || type==2)))
          if (!Options.unownedOnly || t.mapDat[i][5]===false)
            dat.push (t.mapDat[i]);
        }
       }
    }
if (DEBUG_TRACE) DebugTimer.display('SEACHdraw: FILTER');

    document.getElementById('statFound').innerHTML = 'Gefunden: '+ dat.length;
    if (dat.length == 0){
      m = '<BR><CENTER>nichts Gefunden... :/ </center>';
    } else {
      dat.sort(mySort);
if (DEBUG_TRACE) DebugTimer.display('SEACHdraw: SORT');
      if (coordsOnly)
        m = '<TABLE align=center id=srcOutTab cellpadding=2 cellspacing=2><TR style="font-weight: bold"><TD>Koordinate</td></tr>';
      else {
        if (t.opt.searchType == 2) {
      m = '<TABLE id=srcOutTab cellpadding=2 cellspacing=2><TR style="font-weight: bold"><TD>Koordinate</td><TD >Entfernung</td><TD>Stadt</td><TD>Besitzer</td><TD>Macht</td><td>Allianz</td><TD width=80% style="font-size:9px;">Information</td><TD style="padding-left: 10px;"></td></tr>';
    } else {
      if(Options.unownedOnly || t.opt.searchType == 0){
        m = '<TABLE id=srcOutTab cellpadding=2 cellspacing=2><TR style="font-weight: bold"><TD>Koordinate</td><TD style="padding-left: 10px">Entfernung</td><TD style="padding-left: 10px;">Level</td><TD width=80%> &nbsp; Typ</td><TD style=""></td></tr>';
      } else {
        m = '<TABLE id=srcOutTab cellpadding=2 cellspacing=2><TR style="font-weight: bold"><TD>Koordinate</td><TD style="padding-left: 10px">Entfernung</td><TD style="padding-left: 10px;">Level</td><TD>Type</td><TD>Besitzer</td><TD>Macht</td><TD>Allianz</td><TD width=80% style="font-size:9px;">Information</td></tr>';
      }
    }
    }
      var numRows = dat.length;
      if (numRows > 500 && t.searchRunning){
        numRows = 500;
        document.getElementById('srchSizeWarn').innerHTML = '<FONT COLOR=#600000><u>Wichtig</u>: Tabelle zeigt nur 500 von  '+ dat.length +' Ergebnissen an bis die Suche beendet ist!</font>';
      }
      for (i=0; i<numRows; i++){
      m += '<TR valign="top"';
     if (dat[i][12]) m += 'class="pt'+dat[i][12]+'"';
        m += ' ><TD><DIV onclick="ptGotoMapHide('+ dat[i][0] +','+ dat[i][1] +')"><A>'+ dat[i][0] +','+ dat[i][1] +'</a></div></td>';
        if (coordsOnly)
          m += '</tr>';
        else
      if (t.opt.searchType == 2) {
         m += '<TD align="left"  valign="top">'+ dat[i][2].toFixed(2) +' &nbsp; </td><TD align=left>'+ dat[i][8] +'</td><TD valign="top">'+dat[i][9]+'</td><TD valign="top">'+dat[i][10]+'</td><td>'+dat[i][11]+'</td><td>';
         if (dat[i][5]) {
          m += '<DIV onclick="PTscout('+ dat[i][0] +','+ dat[i][1] +');return false;"><A style="font-size:9px;" >Spähen</a></div>';
        } else
          m += '<DIV onclick="PTpd(this, '+ dat[i][7] +')"><A style="font-size:9px;" >Details</a></div>\
          <DIV style="" onclick="PTpd2(this, '+ dat[i][7] +')"><A style="font-size:9px;">Leaderboard</a></div>\
          <DIV style="" onclick="PCpo2(this, '+ dat[i][7] +')"><A style="font-size:9px;">Online Status</a></div>\
          <DIV style="" onclick="PCplo2(this, '+ dat[i][7] +')"><A style="font-size:9px;">Letzter Login</a></div>';
          m+= '</td><TD  valign="top">'+ (dat[i][5]?' Nebel':'') +'</td></tr>';
      } else {
        if(!dat[i][5] || t.opt.searchType == 0){
        m += '<TD align="left"  valign="top">'+ dat[i][2].toFixed(2) +' &nbsp; </td><TD align=left valign="top">'+ dat[i][4] +'</td><TD align="left" valign="top">'+ tileNames[dat[i][3]]+'</td><TD colspan=4>'+ (dat[i][5]?' BESETZ':'') +'</td></tr>';
        } else {
          m += '<TD align="left"  valign="top">'+ dat[i][2].toFixed(2) +' &nbsp; </td><TD align=left valign="top">'+ dat[i][4] +'</td><TD align="left" valign="top">'+ tileNames[dat[i][3]]+'</td><TD valign="top">'+ dat[i][9] +'</td><TD valign="top">'+dat[i][10]+'</td><TD valign="top">'+dat[i][11]+'</td><td>';
          if (dat[i][6]) {
          m += '<DIV onclick="PTscout('+ dat[i][0] +','+ dat[i][1] +');return false;"><A style="font-size:9px;" >Spähen</a></div>';
          } else {
          m += '<DIV onclick="PTpd(this, '+ dat[i][8] +')"><A style="font-size:9px;" >Details</a></div>\
          <DIV style="" onclick="PTpd2(this, '+ dat[i][8] +')"><A style="font-size:9px;">Leaderboard</a></div>\
          <DIV style="" onclick="PCpo2(this, '+ dat[i][8] +')"><A style="font-size:9px;">Online Status</a></div>\
          <DIV style="" onclick="PCplo2(this, '+ dat[i][8] +')"><A style="font-size:9px;">Letzter Login</a></div>';
          }
        m += '</td></tr>';
        }
      }
       }
      m += '</table>';
    }
    document.getElementById('divOutTab').innerHTML = m;
    dat = null;
if (DEBUG_TRACE) DebugTimer.display('SEACHdraw: DRAW');
  },

  mapDat : [],

  gotoMap : function (e){
    coords = e.children[0].innerHTML.split(',');
    hideMe ();
    document.getElementById('mapXCoor').value = coords[0];
    document.getElementById('mapYCoor').value = coords[1];
    unsafeWindow.reCenterMapWithCoor();
    unsafeWindow.changeview_map(document.getElementById('mod_views_map'));
  },
  
  stopSearch : function (msg){
    var t = Tabs.Search;
    document.getElementById ('statStatus').innerHTML = '<FONT color=#ffaaaa>'+ msg +'</font>';
    document.getElementById ('srcStart').value = 'Suche Starten';
    document.getElementById('srchSizeWarn').innerHTML = '';
    t.searchRunning = false;
  },


/** mapdata.userInfo:
(object) u4127810 = [object Object]
    (string) n = George2gh02    (name)
    (string) t = 1              (title code)
    (string) m = 55             (might)
    (string) s = M              (sex)
    (string) w = 2              (mode: 1=normal, 2=begprotect, 3=truce, 4=vacation )
    (string) a = 0              (alliance)
    (string) i = 1              (avatar code)
*****/

  mapCallback : function (left, top, width, rslt){
    function insertRow (x, y, msg){
      row = document.getElementById('srcOutTab').insertRow(-1);
      row.insertCell(0).innerHTML = x +','+ y;
      row.insertCell(1).innerHTML = distance (t.opt.startX, t.opt.startY, x, y);
      row.insertCell(2).innerHTML = msg;
    }
if (DEBUG_TRACE) logit (" 3 mapCallback()");
    var t = Tabs.Search;
    if (!t.searchRunning)
      return;
    if (!rslt.ok){
      t.stopSearch ('FEHLER: '+ rslt.errorMsg);
      return;
    }

    map = rslt.data;
  var userInfo = rslt.userInfo;
    var alliance = rslt.allianceNames;
  
    for (k in map){
      if (t.opt.searchType==0 && map[k].tileType==51 && !map[k].tileCityId ) {  // if barb
        type = 0;
      } else if (t.opt.searchType==1 && map[k].tileType>=10 &&  map[k].tileType<=50) {
        if (map[k].tileType == 10)
          type = 1;
        else if (map[k].tileType == 11)
          type = 2;
        else
          type = (map[k].tileType/10) + 1;
      } else if (t.opt.searchType==2 && map[k].tileCityId >= 0 && map[k].tileType > 50 && map[k].cityName)
      type = 7;
    else
        continue;
      dist = distance (t.opt.startX, t.opt.startY, map[k].xCoord, map[k].yCoord);
      if (dist <= t.opt.maxDistance){
      if (t.opt.searchType==2) {
      var isMisted = map[k].tileUserId == 0 || false;    
      var uu = 'u'+map[k].tileUserId;
      var aU = 'unknown';
      var aD = 'unknown';
      var mightU = 0;
      var nameU = 'unknown';
      if (isMisted) {
        nameU = 'Im Nebel';
        mightU = '';
      } else {
        if (userInfo[uu] ) { // Corrects a problem with hung search.
          nameU = userInfo[uu].n;
          mightU = userInfo[uu].m;
          aD = getDiplomacy(userInfo[uu].a);
          if ( alliance && alliance['a'+userInfo[uu].a] ) {
            aU = alliance['a'+userInfo[uu].a];
          }
          else {
            aU = '---';
            aD = 'Allianzlos';
          }
        }
      }
      t.mapDat.push ([map[k].xCoord, map[k].yCoord, dist, type, map[k].tileLevel, isMisted, map[k].tileCityId, map[k].tileUserId, map[k].cityName,nameU,mightU,aU,aD ]);
    } else {
      isOwned = map[k].tileUserId>0 || map[k].misted;
      if(!isOwned){
        t.mapDat.push ([map[k].xCoord, map[k].yCoord, dist, type, map[k].tileLevel, isOwned]);
      } else {
        var isMisted = map[k].tileUserId == 0 || false;
        var uu = 'u'+map[k].tileUserId;
        var aU = 'unknown';
        var aD = 'unknown';
        var mightU = 0;
        var nameU = 'unknown';
        if (isMisted) {
          nameU = 'Im Nebel';
          mightU = '';
        } else {
          if (userInfo[uu] ) { // Corrects a problem with hung search.
            nameU = userInfo[uu].n;
            mightU = userInfo[uu].m;
            aD = getDiplomacy(userInfo[uu].a);
            if ( alliance && alliance['a'+userInfo[uu].a] ) {
              aU = alliance['a'+userInfo[uu].a];
            }
            else {
              aU = '---';
              aD = 'Allianzlos';
            }
          }
        }
        t.mapDat.push ([map[k].xCoord, map[k].yCoord, dist, type, map[k].tileLevel, isOwned, isMisted, map[k].tileCityId, map[k].tileUserId, nameU, mightU, aU, aD]);
      }
    }
        ++t.tilesFound;
      }
    }
    t.tilesSearched += (15*15);
    document.getElementById('statSearched').innerHTML = 'Durchsucht: '+ t.tilesSearched;
    t.dispMapTable();

    t.curX += 15;
    if (t.curX > t.lastX){
      t.curX = t.firstX;
      t.curY += 15;
      if (t.curY > t.lastY){
        t.stopSearch ('Fertig!');
        return;
      }
    }

    var x = t.normalizeCoord(t.curX);
    var y = t.normalizeCoord(t.curY);
    document.getElementById ('statStatus').innerHTML = 'Durchsuche... '+ x +','+ y;
if (DEBUG_TRACE) logit (" 0 mapCallback()... setTimeout ..:" + x +' , '+ y +' , '+ t.mapCallback.toString().substr (0,50));
    setTimeout (function(){Map.request (x, y, 15, t.mapCallback)}, MAP_DELAY);
  },
};

estimateETA : function(fromCityID,dist,troopSpeed,horseTF) { // Need Relief Station Levels to estimate transport, reinf, or reassign times.
    var ret={ETA:-1,etaStr:'NA',friendETA:-1,friendEtaStr:'NA'};
    if (dist <= 0) return ret;
    if (troopSpeed <=0) return ret;
    var horse = horseTF;
    var baseSpeed = troopSpeed;
    var mmLvl = parseInt(Seed.tech.tch11);//Magical Mapping
    var Speed = 0;
    if (horse==true){
    //HorsesSiegeSpeed = Base * (1 + MM/10) * (1 + AH/20)
      var hsLvl = parseInt(Seed.tech.tch12);//Alloy Horse Shoes
      Speed = baseSpeed * (1 + mmLvl/10) * (1 + hsLvl/20);
    }
    else {
    //FootSpeed = Base * (1 + MM/10)
      Speed = baseSpeed * (1 + mmLvl/10);
    }
    //Grid Speed (tiles/second) = Speed (100ths/min) / 6000
    var gSpeed = 0;
    var estSec = 0;
    if (Speed>0) {
      gSpeed = Speed/6000;
      estSec = (dist/gSpeed).toFixed(0);
    }
    ret.ETA = parseInt((estSec+''))+30;
    ret.etaStr = timestr ( (ret.ETA+'') ,1 );
    //RS - Cities Relief Station Level
    //Friendly Speed = Speed * (1 + RS/2)
    if (fromCityID>0) {
      //logit ('ETAest - cityID: ' + cityID);
      var building = getCityBuilding (fromCityID, 18);//18 is relief station id.
      if (building) {
        fSpeed = Speed * (1 + parseInt(building.maxLevel)/2);
        gSpeed = fSpeed/6000;
        estSec = (dist/gSpeed).toFixed(0);
        ret.friendETA = parseInt((estSec+''))+30;
        ret.friendEtaStr = timestr ((ret.friendETA+''),1);
      }
    }
    return ret;
};

/*******************   KOC Map interface ****************/
Map = {
/***
 0: bog
10: grassland
11: lake
20: woods
30: hills
40: mountain
50: plain
51: city / barb
53: misted city
***/
  generateBlockList : function(left, top, width) {
    var width5 = parseInt(width / 5);
    var bl = [];

    for (x=0; x<width5; x++){
      xx = left + (x*5);
      if (xx > 745)
        xx -= 750;
      for (y=0; y<width5; y++){
        yy = top + (y*5);
        if (yy > 745)
          yy -= 750;
        bl.push ('bl_'+ xx +'_bt_'+ yy);
      }
    }
    return bl.join(",");
  },

  callback : null,
  request : function (left, top, width, cb) {
if (DEBUG_TRACE) logit (" 1 Map.request(): "+ left +' , '+ top +' , '+ width);
    left = parseInt(left / 5) * 5;
    top = parseInt(top / 5) * 5;
    width = parseInt((width+4) / 5) * 5;
    var blockString = this.generateBlockList(left, top, width);
    Map.callback = cb;
    if (unsafeWindow.SANDBOX)
      return RequestMAPTEST(left, top, width, callback);
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.blocks = blockString;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fetchMapTiles.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
if (DEBUG_TRACE) logit (" 2 Map.request  Map = "+ inspect (Map, 2, 1, 2));
        Map.callback(left, top, width, rslt);
      },
      onFailure: function (rslt) {
        Map.callback(left, top, width, rslt);
      }
    });
  },
};


/*************************************** Train Tab ***********************************************/

Tabs.Train = {
  tabLabel : 'Ausbildung',
  tabOrder : 15,
  cont : null,
  timer : null,
  stats : {},
  selectedCity : {},

  init : function (div){
    var t = Tabs.Train;
    t.cont = div;
    s = "<DIV id=trainTopSelect>\
      <DIV class=ptstat>Hier kannst du Truppen Ausbilden und Mauer Verteidigung Bauen</div><DIV style='height:10px'></div><DIV class=ptentry>\
      <DIV style='text-align:center; margin-bottom:10px;'>Heiligtum: &nbsp; <span id=ptspeedcity></span></div>\
      <TABLE class=ptTab width=100%><TR valign=top><TD width=50%>\
      <TABLE align=center><TR><TD align=right>Truppen Typ </td><TD colspan=2>\
      <SELECT id=ptttType>\
        <option value='1'>Versorgungstruppe</option>\
        <option value='2'>Milizsoldat</option>\
        <option value='3'>Späher</option>\
        <option value='4'>Lanzenträger</option>\
        <option value='5'>Schwertkämpfer</option>\
        <option value='6'>Bogenschütze</option>\
        <option value='7'>Kavallerie</option>\
        <option value='8'>Schwere Kavallerie</option>\
        <option value='9'>Versorgungswagen</option>\
        <option value='10'>Ballisten</option>\
        <option value='11'>Rammbock</option>\
        <option value='12'>Steinschleuder</option>\
      </select> &nbsp; max. <span id=ptttSpMax></span></td></tr>\
      <TR><TD align=right># per Slot: </td><TD><INPUT id='ptttInpPS' size=5 type='text' value='0'\></td>\
        <TD><INPUT id='ptttButMaxPS' type=submit value='max'\> &nbsp; max. <span id=ptttSpMaxPS>0</span></td></tr>\
      <TR><TD align=right># Slots: </td><TD><INPUT id='ptttInpSlots' size=2 type='text' value='1'\></td>\
        <TD width=75%><INPUT id='ptttButMaxSlots' type=submit value='max'\> &nbsp; max. <span id=ptttSpMaxSlots>1</span></td></tr>\
      <TR><TD align=right>Du benötigst mehr: </td><td colspan=2><font color=#FF0000><B> <span id=ptttLimiter></span> </b></font></TD></TR>\
      <TR><TD align=right valign=top>Arbeiter Entlassen: </td><TD colspan=2><INPUT type=CHECKBOX id=chkPop"+ (Options.maxIdlePop?' CHECKED ':'') +"> \
        <SPAN style='white-space:normal;'>Erlaubt dir die Feld Arbeiter zu Soldaten Auszubilden! <FONT COLOR=#600000><B>(Feld Produktion wird vorerst eingestellt!)</b></font></span></td></tr>\
      <TR><TD colspan=3 align=center><DIV style='height:10px'></div><INPUT id='ptttButDo' type=submit value='Truppen Ausbilden'\></td></tr>\
      </table></td><TD width=20></td><TD style='border-left:solid 2px;' width=50% align=center>\
      <TABLE align=center><TR><TD align=right>Mauer Bau </td><TD colspan=2>\
      <SELECT id=pttdType>\
        <option value='53'>Fest montierte Armbrüste</option>\
        <option value='55'>Abwehr Trebuchet</option>\
        <option value='60'>Falle</option>\
        <option value='61'>Krähenfüße</option>\
        <option value='62'>Eiserne Erdspieße</option>\
      </select> &nbsp; <span id=pttdSpMax></span></td></tr>\
      <TR><TD align=right># per Slot: </td><TD><INPUT id='pttdInpPS' size=5 type='text' value='0'\></td>\
        <TD><INPUT id='pttdButMaxPS' type=submit value='max'\> &nbsp; max. <span id=pttdSpMaxPS>0</span></td></tr>\
      <TR><TD align=right># Slots: </td><TD><INPUT id='pttdInpSlots' size=2 type='text' value='1'\></td>\
        <TD width=75%><INPUT id='pttdButMaxSlots' type=submit value='max'\> &nbsp; max. <span id=pttdSpMaxSlots>1</span></td></tr>\
      <TR align=center><td align=right>Du benötigst mehr: </td><TD colspan=2 align=left><font color=#FF0000><B> <span id=pttdLimiter></span> </b></font></td></tr>\
      <TR align=center><TD colspan=3><SPAN id=pttdSpace></span></td></tr>\
      <TR><TD colspan=3 align=center><DIV style='height:10px'></div><INPUT id='pttdButDo' type=submit value='Verteidigung Bauen'\></td></tr></table>\
      </td></tr></table></div></div>\
      <TABLE align=center width=425 class=ptTab><TR><TD><div id=ptTrainStatus style='overflow-y:auto; max-height:78px; height: 78px;'></div></td></tr></table>\
      <div style='height: 325px; background: #e8ffe8'>\
      <TABLE width=100% class=ptTab><TR><TD colspan=3><DIV id=divSTtop></div></td></tr>\
      <TR><TD width=50% style='padding-left:15px; padding-right:15px'><DIV style='text-align:center'><B>Warteschlange(n) &nbsp; (<SPAN id=statTTtot></span>)</b><BR><HR></div><DIV id=divSTleft style='overflow-y: auto; height:210px; max-height:210px'></div></td>\
        <TD width=50% style='padding-left:15px; padding-right:15px'><DIV style='text-align:center'><B>Mauer Bau &nbsp; (<SPAN id=statDTtot></span>)</b><BR><HR></div><DIV id=divSTright style='overflow-y: auto; height:210px; max-height:210px'></div></td></tr>\
      </div>";
    t.cont.innerHTML = s;

    var dcp = new CdispCityPicker ('ptspeed', document.getElementById('ptspeedcity'), true, t.clickCitySelect, 0);
    t.TTspMax = document.getElementById ('ptttSpMax');
    t.TTspMaxPS = document.getElementById ('ptttSpMaxPS');
    t.TTspMaxSlots = document.getElementById ('ptttSpMaxSlots');
    t.TTbutMaxSlots = document.getElementById ('ptttButMaxSlots');
    t.TTbutMaxPerSlot = document.getElementById ('ptttButMaxPS');
    t.TTinpPerSlot = document.getElementById ('ptttInpPS');
    t.TTinpSlots = document.getElementById ('ptttInpSlots');
    t.TTselType = document.getElementById ('ptttType');
    t.TTbutDo = document.getElementById ('ptttButDo');
    t.TTlimiter = document.getElementById ('ptttLimiter');
    t.TDspMax = document.getElementById ('pttdSpMax');
    t.TDspMaxPS = document.getElementById ('pttdSpMaxPS');
    t.TDspMaxSlots = document.getElementById ('pttdSpMaxSlots');
    t.TDbutMaxSlots = document.getElementById ('pttdButMaxSlots');
    t.TDbutMaxPerSlot = document.getElementById ('pttdButMaxPS');
    t.TDinpPerSlot = document.getElementById ('pttdInpPS');
    t.TDinpSlots = document.getElementById ('pttdInpSlots');
    t.TDselType = document.getElementById ('pttdType');
    t.TDbutDo = document.getElementById ('pttdButDo');
    t.TDspSpace = document.getElementById ('pttdSpace');
    t.TDlimiter = document.getElementById ('pttdLimiter');
    t.divTrainStatus = document.getElementById ('ptTrainStatus');
          
    t.TTinpSlots.addEventListener ('change', t.updateTopTroops, false);
    t.TTbutMaxPerSlot.addEventListener ('click', t.clickTroopMaxPS, false);
    t.TTbutMaxSlots.addEventListener ('click', t.clickTroopMaxSlots, false);
    t.TTselType.addEventListener ('change', t.changeTroopSelect, false);
    t.TTbutDo.addEventListener ('click', t.clickTroopDo, false);
    t.TDinpSlots.addEventListener ('change', t.updateTopDef, false);
    t.TDselType.addEventListener ('change', t.changeDefSelect, false);
    t.TDbutMaxPerSlot.addEventListener ('click', t.clickDefMaxPS, false);
    t.TDbutMaxSlots.addEventListener ('click', t.clickDefMaxSlots, false);
    t.TDbutDo.addEventListener ('click', t.clickDefDo, false);
    
    document.getElementById ('chkPop').addEventListener ('change', t.clickCheckIdlePop, false);
    t.changeTroopSelect();
    t.changeDefSelect();
  },


  hide : function (){
    var t = Tabs.Train;
    clearTimeout (t.timer);
  },
  
  show : function (){
    var t = Tabs.Train;
    clearTimeout (t.timer);

    t.displayCityStats();
    t.changeTroopSelect();
    t.changeDefSelect();
    t.timer = setTimeout (t.show, 2000);
  },

/*******  TROOPS  ******/  
  
  updateTopTroops : function (){
    var t = Tabs.Train;
    var slots = parseInt(t.TTinpSlots.value, 10);
    if (isNaN(slots) || slots<0)
      slots = 0;
    t.TTspMax.innerHTML = t.stats.MaxTrain;
    t.TTlimiter.innerHTML = t.stats.Limiter;
    t.TTspMaxSlots.innerHTML = t.stats.barracks - t.stats.queued;
    if (slots<1 || (t.stats.barracks-t.stats.queued < 1))
      t.TTspMaxPS.innerHTML = 0;
    else
      t.TTspMaxPS.innerHTML = parseInt(t.stats.MaxTrain / slots);
  },
      
  
  clickTroopMaxPS : function (){
    var t = Tabs.Train;
    var slots = parseInt(t.TTinpSlots.value, 10);
    if (slots<1 || (t.stats.barracks-t.stats.queued < 1))
      t.TTinpPerSlot.value = 0;
    else
      t.TTinpPerSlot.value = parseInt(t.stats.MaxTrain / slots);
  },

  clickTroopMaxSlots : function (){
    var t = Tabs.Train;
    t.TTinpSlots.value = t.stats.barracks - t.stats.queued;
  },
  
  clickCitySelect : function (city){
    var t = Tabs.Train;
    t.selectedCity = city;
    t.lastQueString = null;   
    t.lastDQueString = null;   
    t.displayCityStats ();
    t.changeTroopSelect();
    t.changeDefSelect();
  },
  
  clickCheckIdlePop : function (){
    var t = Tabs.Train;
    if (document.getElementById ('chkPop').checked)
      Options.maxIdlePop = true;
    else
      Options.maxIdlePop = false;
    saveOptions ();
    t.displayCityStats ();
    t.changeTroopSelect ();
  },
  
  changeTroopSelect : function (){
    var t = Tabs.Train;
    var cityId = t.selectedCity.id;
    // unitcost: NAME, Food, Wood, Stone, Ore, Gold, Pop, ?
    var id = t.TTselType.value;
    t.lastTroopSelect = id;
    var uc = unsafeWindow.unitcost['unt'+id];
    var max = 9999999999;
    var limiter = '<blink>Unbekannt</blink>';
    if ( (t.stats.food / uc[1]) < max) {
      max = t.stats.food / uc[1];
      limiter = '<blink>Nahrung</blink>';
    }
    if ( (t.stats.wood / uc[2]) < max) {
      max = t.stats.wood / uc[2];
      limiter = '<blink>Holz</blink>';
    }
    if ( (t.stats.stone / uc[3]) < max) {
      max = t.stats.stone / uc[3];
      limiter = '<blink>Stein';
    }
    if ( (t.stats.ore / uc[4]) < max) {
      max = t.stats.ore / uc[4];
      limiter = '<blink>Erz</blink>';
    }
    if ( (t.stats.idlePop / uc[6]) < max) {
      max = t.stats.idlePop / uc[6];
      limiter = '<blink>Bevölkerung</blink>';
    }
    t.stats.MaxTrain = parseInt (max);
    t.stats.Limiter = limiter;
    if (t.stats.MaxTrain < 0)
      t.stats.MaxTrain = 0;
    if (matTypeof(uc[8]) == 'object'){
      for (k in uc[8]){  // check building requirement
        var b = getCityBuilding (cityId, k.substr(1));
        if (b.maxLevel < uc[8][k][1]){
          t.stats.MaxTrain = 0;
          t.stats.Limiter = '<blink>Gebäude/Upgrade';
          break;
        }
      }
    }
    if (matTypeof(uc[9]) == 'object'){
      for (k in uc[9]){    // check tech requirement
        if (parseInt(Seed.tech['tch'+k.substr(1)]) < uc[9][k][1]){
          t.stats.MaxTrain = 0;
          t.stats.Limiter = '<blink>Forschung</blink>';
          break;
        }
      }
    }
    t.updateTopTroops();
  },
  
  clickTroopDo : function (){
    var t = Tabs.Train;
    var cityId = t.selectedCity.id;
    var unitId = t.TTselType.value;
    var perSlot = parseInt(t.TTinpPerSlot.value, 10);
    var numSlots = parseInt(t.TTinpSlots.value, 10);
    
    t.displayCityStats ();
    if (perSlot<1){
      t.divTrainStatus.innerHTML = '<FONT COLOR=#550000>Die Anzahl der Slots muss mind. <blink>1</blink> betragen...</font>';
      return;
    }
    if (perSlot*numSlots > t.stats.MaxTrain){
      t.divTrainStatus.innerHTML = '<FONT COLOR=#550000>Kann nicht so viele Truppen Ausbilden! <blink>'+ t.stats.MaxTrain +' </blink>ist dein max. !</font>';
      return;
    }
    if (numSlots<1 || numSlots>t.stats.barracks - t.stats.queued){
      t.divTrainStatus.innerHTML = '<FONT COLOR=#550000><blink>Fehlerhafte Slot anzahl!</blink></font>';
      return;
    }
    t.setBusy(true);
    var que = [];
    for (var i=0; i<numSlots; i++)
      que.push (['T', unitId, parseInt (perSlot)]);
    t.divTrainStatus.innerHTML = '';
    t.doQueue (cityId, que);
  },

  
/*******  DEF  ******/  
  
  updateTopDef : function (){
    var t = Tabs.Train;
    var slots = parseInt(t.TDinpSlots.value, 10);
    if (isNaN(slots) || slots<0)
      slots = 0;
    t.TDspMax.innerHTML = 'max. '+ t.stats.MaxDefTrain +'&nbsp; <BR>Du Besitz: '+ t.stats.defOwned;   
    t.TDlimiter.innerHTML = t.stats.DefLimiter;
    t.TDspMaxSlots.innerHTML = t.stats.wallLevel-t.stats.Dqueued;
    if (slots<1)
      t.TDspMaxPS.innerHTML = 0;
    else
      t.TDspMaxPS.innerHTML = parseInt(t.stats.MaxDefTrain / slots);

    t.TDspSpace.innerHTML = 'Mauer Level: <B>'+ t.stats.wallLevel +'</b><BR>Verteidigungswall: '+ (t.stats.wallSpaceUsed+t.stats.wallSpaceQueued)  +'/<B>'+ t.stats.wallSpace +'</b><BR>\
        Feldabwehr: '+ (t.stats.fieldSpaceUsed+t.stats.fieldSpaceQueued) +'/<B>'+ t.stats.fieldSpace +'</b>';
  },

  changeDefSelect : function (){
    var t = Tabs.Train;
    var cityId = t.selectedCity.id;
    // unitcost: NAME, Food, Wood, Stone, Ore, Gold, Pop, ?
    var id = t.TDselType.value;
    t.lastDefSelect = id;
    t.stats.defOwned = parseInt(Seed.fortifications['city' + cityId]['fort'+id]);    
    var uc = unsafeWindow.fortcost['frt'+id];
    var max = 9999999999;
    var limiter = '<blink>Unbekannt</blink>';
    if ( (t.stats.food / uc[1]) < max) {
      max = t.stats.food / uc[1];
      limiter = '<blink>Nahrung</blink>';
    }
    if ( (t.stats.wood / uc[2]) < max) {
      max = t.stats.wood / uc[2];
      limiter = '<blink>Holz</blink>';
    }
    if ( (t.stats.stone / uc[3]) < max) {
      max = t.stats.stone / uc[3];
      limiter = '<blink>Stein</blink>';
    }
    if ( (t.stats.ore / uc[4]) < max) {
      max = t.stats.ore / uc[4];
      limiter = '<blink>Erz</blink>';
    }
    if ( (t.stats.idlePop / uc[6]) < max) {
      max = t.stats.idlePop / uc[6];
      limiter = '<blink>Bevölkerung</blink>';
    }
    t.stats.MaxDefTrain = parseInt (max);
    if (t.stats.MaxDefTrain < 0)
      t.stats.MaxDefTrain = 0;
    if (matTypeof(uc[8]) == 'object'){
      for (k in uc[8]){  // check building requirement
        var b = getCityBuilding (cityId, k.substr(1));
        if (b.maxLevel < uc[8][k][1]){
          t.stats.MaxDefTrain = 0;
          t.stats.DefLimiter = '<blink>Gebäude/Upgrade</blink>';
          break;
        }
      }
    }
    if (matTypeof(uc[9]) == 'object'){
      for (k in uc[9]){    // check tech requirement
        if (parseInt(Seed.tech['tch'+k.substr(1)]) < uc[9][k][1]){
          t.stats.MaxDefTrain = 0;
          t.stats.DefLimiter = '<blink>Forschung</blink>';
          break;
        }
      }
    }

    var spaceEach = parseInt(unsafeWindow.fortstats["unt"+ id][5]);
    if (id<60)
      var spaceAvail = t.stats.wallSpace - t.stats.wallSpaceUsed - t.stats.wallSpaceQueued;
    else
      var spaceAvail = t.stats.fieldSpace - t.stats.fieldSpaceUsed - t.stats.fieldSpaceQueued;
    if ( t.stats.MaxDefTrain * spaceEach > spaceAvail) {
      t.stats.MaxDefTrain = parseInt(spaceAvail / spaceEach);
      if (id<60)
        t.stats.DefLimiter = '<blink>Verteidigungswall</blink>';
      else
        t.stats.DefLimiter = '<blink>Feldabwehr</blink>';
    }
    t.updateTopDef();
  },
  
  clickDefMaxPS : function (){
    var t = Tabs.Train;
    var slots = parseInt(t.TDinpSlots.value, 10);
    if (slots<1)
      t.TDinpPerSlot.value = 0;
    else
      t.TDinpPerSlot.value = parseInt(t.stats.MaxDefTrain / slots);
  },

  clickDefMaxSlots : function (){
    var t = Tabs.Train;
    t.TDinpSlots.value = t.stats.wallLevel-t.stats.Dqueued;
  },
    
  clickDefDo : function (){
    var t = Tabs.Train;
    var cityId = t.selectedCity.id;
    var unitId = t.TDselType.value;
    var perSlot = parseInt(t.TDinpPerSlot.value, 10);
    var numSlots = parseInt(t.TDinpSlots.value, 10);
    
    t.displayCityStats ();
    if (perSlot<1){
      t.divTrainStatus.innerHTML = '<FONT COLOR=#550000>Die Anzahl der Slots muss mind. 1 betragen...</font>';
      return;
    }
    if (perSlot*numSlots > t.stats.MaxDefTrain){
      t.divTrainStatus.innerHTML = '<FONT COLOR=#550000>Kann nicht so viele Truppen Ausbilden! '+ t.stats.MaxDefTrain +' ist dein max.</font>';
      return;
    }
    if (numSlots<1 || numSlots > t.stats.wallLevel-t.stats.Dqueued){
      t.divTrainStatus.innerHTML = '<FONT COLOR=#550000>Fehlerhafte Slot Anzahl!</font>';
      return;
    }
    t.setBusy(true);
    var que = [];
    for (var i=0; i<numSlots; i++)
      que.push (['T', unitId, parseInt (perSlot)]);
    t.divTrainStatus.innerHTML = '';
    t.doDefQueue (cityId, que);
  },

  doDefQueue : function (cityId, que, errMsg){
    var t = Tabs.Train;
    try {
      t.displayCityStats();
      if (errMsg){
        t.dispTrainStatus ('<font color=#550000><B>ERROR: '+ errMsg +'</b></font><BR>');
        t.setBusy(false);
        return;
      }
      var cmd = que.shift();
      if (!cmd){
        t.dispTrainStatus ('<B>Bau Aufträge wurden in Auftrag gegeben!</b><BR>');
        t.setBusy(false);
        return;
      }
      if (cmd[0] == 'T'){
        t.dispTrainStatus (''+ cmd[2] +' '+  fortNamesShort[cmd[1]] +' werden Gebaut!<BR>');
        doDefTrain ( cityId, cmd[1], cmd[2],
          function(errMsg){
            setTimeout(function (){Tabs.Train.doDefQueue(cityId, que, errMsg);}, (Math.random()*3500)+1500);
          } );
      }
    } catch (err) {
      logit (inspect (err, 8, 1));
      t.dispTrainStatus ('<font color=#550000>PROGRAMM FEHLER: '+ err.message +'</font><BR>');
      t.setBusy(false);
    }
  },
  

  setBusy : function (tf){
    var t = Tabs.Train;
    t.TDbutDo.disabled = tf;
    t.TTbutDo.disabled = tf;
  },

  // fix KofC bugs ....
  // if first start time > now, make it now
  // if any end time != next start time, fix it
  fixQueTimes : function (q){
    var now = unixTime();
    if (q[0][2] > now)
      q[0][2] = now;
    for (var i=0; i<q.length; i++){
      if (q[i+1]!=null && q[i+1][2]!=q[i][3])
        q[i][3] = q[i+1][2];
    }        
  },
  
  displayCityStats : function (){
    var t = Tabs.Train;
    var cityId = t.selectedCity.id;
    t.stats.food = parseInt (Seed.resources['city'+cityId].rec1[0]/3600);
    t.stats.wood = parseInt (Seed.resources['city'+cityId].rec2[0]/3600);
    t.stats.stone = parseInt (Seed.resources['city'+cityId].rec3[0]/3600);
    t.stats.ore = parseInt (Seed.resources['city'+cityId].rec4[0]/3600);
    t.stats.gold = Seed.citystats['city'+cityId].gold[0];
    if (Options.maxIdlePop)
      t.stats.idlePop = parseInt(Seed.citystats['city'+cityId].pop[0]);
    else
      t.stats.idlePop = parseInt(Seed.citystats['city'+cityId].pop[0]) - parseInt(Seed.citystats['city'+cityId].pop[3]);
    t.stats.barracks = getCityBuilding (cityId, 13).count;
    var m = '<CENTER><B>'+ Cities.byID[cityId].name +' &nbsp; ('+ Cities.byID[cityId].x +','+ Cities.byID[cityId].y +')</b></center><HR>';
  
m += '<TABLE class=ptTab width=100%><TR align=center>\
        <TD width=8%><B><u>Versorger</u></b></td><TD width=8%><B><u>Miliz</u></b></td><TD width=8%><B><u>Späher</u></b></td>\
        <TD width=8%><B><u>Lanzen</u></b></td><TD width=8%><B><u>Schwerter</u></b></td><TD width=8%><B><u>Bogen</u></b></td>\
        <TD width=8%><B><u>Kav</u></b></td><TD width=8%><B><u>S-Kav</u></b></td><TD width=8%><B><u>Wagen</u></b></td>\
        <TD width=8%><B><u>Ballis</u></b></td><TD width=8%><B><u>Ram</u></b></td><TD width=8%><B><u>Kat</u></b></td><tr>';
    
 m += '<TR align=center><TD width=8%>'+Seed.units['city'+cityId]['unt1']+'</td><TD width=8%>'+Seed.units['city'+cityId]['unt2']+
 '<TD width=8%>'+Seed.units['city'+cityId]['unt3']+'</td><TD width=8%>'+Seed.units['city'+cityId]['unt4']+
 '<TD width=8%>'+Seed.units['city'+cityId]['unt5']+'</td><TD width=8%>'+Seed.units['city'+cityId]['unt6']+
 '<TD width=8%>'+Seed.units['city'+cityId]['unt7']+'</td><TD width=8%>'+Seed.units['city'+cityId]['unt8']+
 '<TD width=8%>'+Seed.units['city'+cityId]['unt9']+'</td><TD width=8%>'+Seed.units['city'+cityId]['unt10']+
 '<TD width=8%>'+Seed.units['city'+cityId]['unt11']+'</td><TD width=8%>'+Seed.units['city'+cityId]['unt12']+'</td><tr></table>';
  
    m += '<TABLE class=ptTab width=100%><TR align=center>\
        <TD width=18%><B>Nahrung</b></td><TD width=16%><B>Holz</b></td><TD width=16%><B>Stein</b></td>\
        <TD width=16%><B>Erz</b></td><TD width=16%><B>Gold</b></td><TD width=16%><B>Müßige Bevölkerung</b></td></tr>\
      <TR align=center><TD>'+ addCommasInt(t.stats.food) +'</td><TD>'+ addCommasInt(t.stats.wood) +'</td><TD>'+ addCommasInt(t.stats.stone) +'</td>\
        <TD>'+ addCommasInt(t.stats.ore) +'</td><TD>'+ addCommasInt(t.stats.gold) +'</td>\
        <TD>'+ addCommasInt(t.stats.idlePop) +'</td></tr></table><BR>';
    document.getElementById ('divSTtop').innerHTML = m;
    
// troop queue ....
    var totTime = 0;
    var q = Seed.queue_unt['city'+cityId];
    var qs = q.toString();
    var now = unixTime();
    if (q!=null && q.length>0)
      totTime = q[q.length-1][3] - now;
    if ( qs == t.lastQueString){
      if (q!=null && q.length>0){
        var cur = q[0][3] - now;
        if (cur < 1)
          q.shift();
        document.getElementById ('ptttfq').innerHTML = timestr(cur, true);
      }
    } else {
      t.lastQueString = qs;
      t.stats.queued = 0;
      m = '<TABLE align=center class=ptTab>';
      if (q!=null && q.length>0 ){
        t.fixQueTimes (q);
        t.stats.queued = q.length;
        first = true;
        for (var i=0; i<q.length; i++){
          start = q[i][2];
          end = q[i][3];
          if (first)
            actual = end - now;
          else
            actual = end - lastEnd;
          if (actual < 0)
            actual = 0;
          m += '<TR align=right><TD>'+ q[i][1] +' </td><TD align=left> '+ unsafeWindow.unitcost['unt'+q[i][0]][0];
          if (first)
            m += '</td><TD> &nbsp; '+  timestr(end-start, true) +'</td><TD> (<SPAN id=ptttfq>'+ timestr(actual, true) +'</span>)';
          else
            m += '</td><TD> &nbsp; '+  timestr(actual, true) +'</td></tr>';
          lastEnd = end;
          first = false;
        }
      }
      m += '</table>';
      document.getElementById ('divSTleft').innerHTML = m;
    }
    m = t.stats.barracks +' Kasernen';
    if (t.stats.queued > 0)
      m += ', '+ t.stats.queued +' Slots';
    if (totTime > 0)
      m += ', '+ unsafeWindow.timestr(totTime);
    document.getElementById ('statTTtot').innerHTML = m;
    
// defense queue ....
    getWallInfo (cityId, t.stats);    
    var totTime = 0;
    var q = Seed.queue_fort['city'+cityId];
    var qs = q.toString();
    if (q!=null && q.length>0)
      totTime = q[q.length-1][3] - now;
    if ( qs == t.lastDQueString){
      if (q!=null && q.length>0){
        var cur = q[0][3] - now;
        if (cur < 1)
          q.shift();
        document.getElementById ('pttdfq').innerHTML = timestr(cur, true);
      }
    } else {
      t.lastDQueString = qs;
      t.stats.Dqueued = 0;
      t.stats.wallSpaceQueued = 0;
      t.stats.fieldSpaceQueued = 0;
      m = '<TABLE align=center class=ptTab>';
      if (q!=null && q.length > 0 ){
        t.fixQueTimes (q);
        t.stats.Dqueued = q.length;
        first = true;
        for (i=0; i<q.length; i++){
          if (q[i][0] < 60)          
            t.stats.wallSpaceQueued += parseInt(unsafeWindow.fortstats["unt"+ q[i][0]][5]) * parseInt(q[i][1]);
          else          
            t.stats.fieldSpaceQueued += parseInt(unsafeWindow.fortstats["unt"+ q[i][0]][5]) * parseInt(q[i][1]);
          start = q[i][2];
          end = q[i][3];
          if (first)
            actual = end - now;
          else
            actual = end - lastEnd;
          if (actual < 0)
            actual = 0;
          m += '<TR align=right><TD>'+ q[i][1] +' </td><TD align=left> '+ fortNamesShort[q[i][0]];
          if (first)
            m += '</td><TD> &nbsp; '+  timestr(end-start, true) +'</td><TD> (<SPAN id=pttdfq>'+ timestr(actual, true) +'</span>)';
          else
            m += '</td><TD> &nbsp; '+  timestr(actual, true) +'</td></tr>';
          lastEnd = end;
          first = false;
        }
      }
      m += '</table>';
      document.getElementById ('divSTright').innerHTML = m;
    }
    m = t.stats.Dqueued +' Slots';
    if (totTime > 0)
      m += ', '+ unsafeWindow.timestr(totTime);
    document.getElementById ('statDTtot').innerHTML = m;
  },

  dispTrainStatus : function (msg){
    var t = Tabs.Train;
    t.divTrainStatus.innerHTML = msg + t.divTrainStatus.innerHTML;
  },

  doQueue : function (cityId, que, errMsg){
    var t = Tabs.Train;
    try {
      t.displayCityStats();
      if (errMsg){
        t.dispTrainStatus ('<font color=#550000><B>ERROR: '+ errMsg +'</b></font><BR>');
        t.setBusy(false);
        return;
      }
      var cmd = que.shift();
      if (!cmd){
        t.dispTrainStatus ('<B>Truppen erfolgreich Rekrutiert!</b><BR>');
        t.setBusy(false);
        return;
      }
      if (cmd[0] == 'T'){
        t.dispTrainStatus (''+ cmd[2] +' '+  unsafeWindow.unitcost['unt'+cmd[1]][0] +' werden Ausgebildet!<BR>');
        doTrain (cityId, cmd[1], cmd[2],
          function(errMsg){
           setTimeout(function (){Tabs.Train.doQueue(cityId, que, errMsg);}, (Math.random()*3500)+1500 );
          }
        );
      }
    } catch (err) {
      logit (inspect (err, 8, 1));
      t.dispTrainStatus ('<font color=#550000>PROGRAM ERROR: '+ err.message +'</font><BR>');
      t.setBusy(false);
    }
  },
}
/*************************************** OVERVIEW TAB ************************************************/
var GMTclock = {
  span : null,
  timer : null,
  
  init : function (){
    this.span = document.createElement ('span');
    this.span.style.fontWeight = 'bold';
    document.getElementById('kochead_time').parentNode.appendChild (this.span);
    this.setEnable (Options.gmtClock);
  },

  setEnable : function (tf){
    var t = GMTclock;
    clearInterval (t.timer);
    if (tf){
      t.timer = setInterval (t.everySecond, 900);
    } else {
      t.span.innerHTML = '';
    }
  },
    
  everySecond : function (){
    var now = new Date();  
    now.setTime(now.getTime() + (now.getTimezoneOffset()*60000));
    GMTclock.span.innerHTML = ' &nbsp; | '+ now.toLocaleFormat('%H:%M:%S') +' ';
  },
}


function getResourceProduction (cityId){
  var ret = [0,0,0,0,0];
  var now = unixTime ();
  
  var wilds = [0, 0, 0, 0, 0];
  var w = Seed.wilderness["city" + cityId];
  for (var k in w){
    var type = parseInt(w[k].tileType);
    if (type==10 || type==11)
      wilds[1] += parseInt(w[k].tileLevel);
    else
      wilds[type/10] += parseInt(w[k].tileLevel);
  }  
  
  knight = 0;       
  var s = Seed.knights["city" + cityId];
  if (s) {
    s = s["knt" + Seed.leaders["city" + cityId].resourcefulnessKnightId];
    if (s){
      var knight = parseInt(s.resourcefulness);
      if (s.resourcefulnessBoostExpireUnixtime > now)
        knight *= 1.25;
    }
  }
  var workerFactor = 1;
  var c = parseInt(Seed.citystats["city" + cityId]["pop"][0]);  // Current  population
  var w = parseInt(Seed.citystats["city" + cityId]["pop"][3]);  // Labor force
  if (w > c)
    workerFactor = c / w;
  
  for (var i=1; i<5; i++){
    var usage = Seed.resources["city" + cityId]["rec" + i];
    var items = 0;
    if (parseInt(Seed.playerEffects["r" + i + "BstExp"]) > now) {
      items = 0.25;
    }
    var tech = Seed.tech["tch" + i];
    ret[i] = parseInt((usage[2] * (1 + tech/10 + knight/100 + items + 0.05 * wilds[i]) * workerFactor + 100));
  }
  return ret;  
}
Tabs.Overview = {
  tabLabel : 'Stats',
  tabOrder : 1,
  cont : null,
  displayTimer : null,

  Overview : function (){
  },

  init : function (div){
    this.cont = div;
    if (Options.overviewAllowOverflow)
      this.cont.style.overflowX = 'visible';
  },

  hide : function (){
    clearTimeout (Tabs.Overview.displayTimer);
  },
  
  show : function (){
    var rownum = 0;
    var t = Tabs.Overview;

    clearTimeout (t.displayTimer);

    function _row (name, row, noTotal){
      if (rownum++ % 2)
        style = '';
      else
        style = ' style = "background: #e8e8e8"';
      var tot = 0;
      var m = [];
      m.push ('<TR style="background: #FFF" align=right');
      m.push (style);
      m.push ('><TD');
      m.push (style);
      m.push ('><B>');
      m.push (name);
      m.push (' &nbsp; </td>');
      if (noTotal){
        m.push ('<TD');
        m.push (style);
        m.push ('> &nbsp;</td>');
      } else {
        for (i=0; i<row.length; i++)
          tot += row[i];
        m.push ('<TD style="background: #600000;color: #FFF">');
if (TEST_WIDE)
  m.push ('X,');        
        m.push (addCommas(tot));
        m.push ('</td>');
      }
      for (i=0; i<row.length; i++){
        m.push ('<TD');
        m.push (style);
        m.push ('>');
if (TEST_WIDE)
  m.push ('X,');        
        m.push (addCommas(row[i]));
        m.push ('</td>');
      }
      m.push ('</tr>');
      return m.join('');
    }
    
//DebugTimer.start();
    try {
      if (Options.includeMarching)
        march = getMarchInfo ();

      dt = new Date ();
      dt.setTime (Seed.player.datejoinUnixTime * 1000);
      
      str = '<DIV class=ptstat style="margin-top:5px; margin-bottom:5px;"><TABLE cellspacing=0 cellpadding=0 class=ptTab width=97% align=center>\
        <TR align=left><TD><SPAN class=ptStatLight>Dabei seid:</span> '+ dt.toLocaleDateString() +'</td>\
        <TD><SPAN class=ptStatLight>Macht:</span> ' + addCommas(Seed.player.might) +'</td>\
        <TD><SPAN class=ptStatLight>Allianz:</span> ' + getMyAlliance()[1] +'</td>\
        <TD align=right><SPAN class=ptStatLight>Domain:</span> ' + unsafeWindow.domainName +'</td></tr></table></div>';

              
      str += "<DIV id=overMainDiv style='font-size:"+ Options.overviewFontSize +"px'><TABLE class=ptTabOverview cellpadding=0 cellspacing=0><TR valign=top align=right><TD width=65><b>Stadt Name</b><br>(Koordinate)<br>Provinz</td><TD width=88 style='background: #600000;color: #FFF'><B>Gesamt</b></td>";
      for(i=0; i<Cities.numCities; i++) {
        str += "<TD width=81><B>"+ Cities.cities[i].name.substring(0,11) +'</b><BR>'+ coordLink (Cities.cities[i].x, Cities.cities[i].y) +"<BR>"+ unsafeWindow.provincenames['p'+ Cities.cities[i].provId] +"</td>";
      }
      if (Options.includeMarching)
        str += '<TD width=81><B>Marsch</b></td>';
      str += "</tr>";
    if (Options.includeWachturm) {
    str += '<TR valign=top align=right><TD style=\'background: #CCFFCC\'><b>Wachturm</b></td><TD style=\'background: #CCFFCC\'></td>';
    for(i=0; i<Cities.numCities; i++){
      cityID = 'city'+Cities.cities[i].id;
      Gate = parseInt(Seed.citystats[cityID].gate);
    if(Gate == 0)
      str += '<TD style=\'background: #CCFFCC\'>Versteckt</td>';
    else
      str += '<TD style=\'background: #CCFFCC\' ><SPAN class=boldRed><blink>Verteidigung</blink></span></td>';

    }
    }
      rows = [];
      rows[0] = [];
      for(i=0; i<Cities.numCities; i++) {
        cityID = 'city'+ Cities.cities[i].id;
        rows[0][i] = parseInt(Seed.citystats[cityID].gold[0]);
      }
      for (r=1; r<5; r++){
        rows[r] = [];
        for(i=0; i<Cities.numCities; i++) {
          cityID = 'city'+ Cities.cities[i].id;
          rows[r][i] = parseInt(Seed.resources[cityID]['rec'+r][0] / 3600);
        }
      }
  
      if (Options.includeMarching){
        for (var i=0; i<5; i++)
          rows[i][Cities.numCities] = march.resources[i];
      }
            if (Options.includeRessis) {
      str += _row ('Gold', rows[0]);
      str += _row ('Nahrung', rows[1]);
      str += _row ('Holz', rows[2]);
      str += _row ('Stein', rows[3]);
      str += _row ('Erz', rows[4]);
        }
      for (r=1; r<13; r++){
        rows[r] = [];
        for(i=0; i<Cities.numCities; i++) {
          cityID = 'city'+ Cities.cities[i].id;
          rows[r][i] = parseInt(Seed.units[cityID]['unt'+r]);
        }
      }
      if (Options.includeMarching){
        for (var i=0; i<13; i++)
          rows[i][Cities.numCities] = march.marchUnits[i];
      }
      if (Options.includeTraining){
        var q = Seed.queue_unt;
        for(i=0; i<Cities.numCities; i++) {
          q = Seed.queue_unt['city'+ Cities.cities[i].id];
          if (q && q.length>0){
            for (qi=0; qi<q.length; qi++)
              rows[q[qi][0]][i] += parseInt(q[qi][1]);
          }    
        }
      }
    t_rows = [];
    for (r=2; r<26; r+=2){
        t_rows[r] = [];
        for(j=0; j<Cities.numCities; j++) {
       t_rows[r][j] = [0];
          cityID = 'city'+ Cities.cities[j].id;    
          var q = Seed.queue_unt[cityID];
          var supply_t=militia_t=scout_t=pike_t=sword_t=archer_t=cavalry_t=heavy_t=wagon_t=ballista_t=ram_t=catapult_t=0 ;     
           for (var i=0; i<q.length; i++){
        switch(q[i][0])
        {
            case '1':
          supply_t += parseInt(q[i][1]);
         break;
        case '2':
          militia_t += parseInt(q[i][1]);
          break;
        case '3':
          scout_t += parseInt(q[i][1]);
          break;
        case '4':
          pike_t += parseInt(q[i][1]);
          break;
        case '5':
          sword_t += parseInt(q[i][1]);
          break;
        case '6':
         archer_t += parseInt(q[i][1]);
          break;
        case '7':
          cavalry_t += parseInt(q[i][1]);
          break;
        case '8':
          heavy_t += parseInt(q[i][1]);
          break;
        case '9':
         wagon_t += parseInt(q[i][1]);
          break;
        case '10':
          ballista_t += parseInt(q[i][1]);
          break;
          case '11':
          ram_t += parseInt(q[i][1]);
          break;
        case '12':
          catapult_t += parseInt(q[i][1]);
              break;
      }
        switch(r)
        {
          case 2:
          t_rows[r][j] = supply_t;
        break;
          case 4:
          t_rows[r][j] = militia_t;
        break;
          case 6:
          t_rows[r][j] = scout_t;
        break;
          case 8:
          t_rows[r][j] = pike_t;
        break;
          case 10:
          t_rows[r][j] = sword_t;
        break;
          case 12:
          t_rows[r][j] = archer_t;
        break;
          case 14:
          t_rows[r][j] = cavalry_t;
        break;
          case 16:
          t_rows[r][j] = heavy_t;
        break;
          case 18:
          t_rows[r][j] = wagon_t;
        break;
          case 20:
          t_rows[r][j] = ballista_t;
        break;
          case 22:
          t_rows[r][j] = ram_t;
        break;
          case 24:
          t_rows[r][j] = catapult_t;
        break;
        
      }
          }  
        }
    }  
     row = [];
      for(i=0; i<Cities.numCities; i++) {
        var rp = getResourceProduction (Cities.cities[i].id);
        var usage = parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][3]);
        row[i] = rp[1] - usage;
      }
    if (Options.includeNahrung) {
      str += '<TR><TD class=ptstat>Nahrung</td></tr>';
      str += _row ('Verbrauch +/-', row, true);
      
      for(i=0; i<Cities.numCities; i++) {
        if (row[i] >= 0)
          row[i] = '----';
        else {
          var timeLeft = parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][0]) / 3600 / (0-row[i]) * 3600;
          if (timeLeft > 86313600)
            row[i] = '----';
          else {
            if (Options.enableFoodWarn && timeLeft<(Options.foodWarnHours*3600))
              row[i] = '<blink><SPAN class=whiteOnRed>'+ timestrShort(timeLeft) +'</span></blink>';
            else
              row[i] = timestrShort(timeLeft);
          }
        }
      }    
      str += _row ('Reicht für', row, true);
    }
      rownum = 0;
     if (Options.includeTruppen) {
    str += '<TR><TD class=ptstat>Truppen</td></tr>';
      str += _row ('Versorger', rows[1]);
      str += _row ('Miliz', rows[2]);
      str += _row ('Späher', rows[3]);
      str += _row ('Lanzen', rows[4]);
      str += _row ('Schwerter', rows[5]);
      str += _row ('Bogen', rows[6]);
      str += _row ('Kav', rows[7]);
      str += _row ('S-Kav', rows[8]);
      str += _row ('Wagen', rows[9]);
      str += _row ('Ballisten', rows[10]);
      str += _row ('Rammbock', rows[11]);
      str += _row ('Katapulte', rows[12]);
  }
          if (Options.includeTraining) {
    str += '<TR><TD class=ptstat>Ausbildung</td></tr>';
        str += _row ('<i><span style="color:green">Versorger</span></i>', t_rows[2]);
        str += _row ('<i><span style="color:green">Miliz</span></i>', t_rows[4]);
        str += _row ('<i><span style="color:green">Späher</span></i>', t_rows[6]);
        str += _row ('<i><span style="color:green">Lanzen</span></i>', t_rows[8]);
        str += _row ('<i><span style="color:green">Schwerter</span></i>', t_rows[10]);
        str += _row ('<i><span style="color:green">Bogen</span></i>', t_rows[12]);
        str += _row ('<i><span style="color:green">Kav</span></i>', t_rows[14]);
        str += _row ('<i><span style="color:green">S-Kav</span></i>', t_rows[16]);
        str += _row ('<i><span style="color:green">Wagen</span></i>', t_rows[18]);
        str += _row ('<i><span style="color:green">Ballisten</span></i>', t_rows[20]);
        str += _row ('<i><span style="color:green">Rammbock</span></i>', t_rows[22]);
        str += _row ('<i><span style="color:green">Katapulte</span></i>', t_rows[24]);
      }

      row = [];
      for(i=0; i<Cities.numCities; i++) {
        var rp = getResourceProduction (Cities.cities[i].id);
        var usage = parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][3]);
        row[i] = rp[1] - usage;
      }
          if (Options.includeNahrungUnten) {
      str += '<TR><TD class=ptstat>Nahrung</td></tr>';
      str += _row ('Verbrauch +/-', row, true);
      
      for(i=0; i<Cities.numCities; i++) {
        if (row[i] >= 0)
          row[i] = '----';
        else {
          var timeLeft = parseInt(Seed.resources["city" + Cities.cities[i].id]['rec1'][0]) / 3600 / (0-row[i]) * 3600;
          if (timeLeft > 86313600)
            row[i] = '----';
          else {
            if (Options.enableFoodWarn && timeLeft<(Options.foodWarnHours*3600))
              row[i] = '<blink><SPAN class=whiteOnRed>'+ timestrShort(timeLeft) +'</span></blink>';
            else
              row[i] = timestrShort(timeLeft);
          }
        }
      }    
      str += _row ('Reicht für', row, true);
        }
          if (Options.includeInfos) {
      str += '<TR><TD class=ptstat>Info</td></tr>';
      
      row = [];
      for(i=0; i<Cities.numCities; i++) {
        var totWilds = 0;
        dat = Seed.wilderness['city'+ Cities.cities[i].id];
        if (dat!=null && matTypeof(dat)=='object')
          for (k in dat)
            ++totWilds;
        var castle = parseInt(Seed.buildings['city'+ Cities.cities[i].id].pos0[1]);
        if (totWilds < castle)
          row[i] = '<SPAN class=boldRed><B>'+ totWilds +'/'+ castle +'</b></span>';
        else
          row[i] = totWilds +'/'+ castle;
      }
      str += _row ('Wildnisse', row, true);
  
      row = [];
      for(i=0; i<Cities.numCities; i++) {
        totKnights = 0;
        dat = Seed.knights['city'+ Cities.cities[i].id];
        for (k in dat)
          ++totKnights;
        row[i] = totKnights;
      }
      str += _row ('Ritter', row, true);
  
      var now = unixTime();
      var row = [];
      for(i=0; i<Cities.numCities; i++) {
        var totTime = 0;
        var q = Seed.queue_unt['city'+Cities.cities[i].id];
        if (q!=null && q.length>0)
          totTime = q[q.length-1][3] - now;
        if (totTime < 0)
          totTime = 0;
        if (totTime < 3600)
          row[i] = '<SPAN class=boldRed><B>'+ timestr(totTime) +'</b></span>';
        else
          row[i] = timestr(totTime);
      }
      str += _row ('Warteschlange', row, true);
      
      var row = [];
      for(i=0; i<Cities.numCities; i++) {
        var wall = {};
        getWallInfo (Cities.cities[i].id, wall);
        var totTime = 0;
        var q = Seed.queue_fort['city'+Cities.cities[i].id];
        if (q!=null && q.length>0)
          totTime = q[q.length-1][3] - now;
        if (totTime < 0)
          totTime = 0;
        if (totTime<1 && (wall.wallSpaceUsed < wall.wallSpace-4 || wall.fieldSpaceUsed < wall.fieldSpace-4))
          row[i] = '<SPAN class=boldRed><B>'+ timestr(totTime) +'</b></span>';
        else
          row[i] = timestr(totTime);
      }    
      str += _row ('MauerBau', row, true);
    }
    str += '<TR><TD class=xtab></td><TD class=xtab colspan=8><b><u>Ansicht Einstellung</u></b><BR><INPUT type=CHECKBOX id=ptIncWachturm'+ (Options.includeWachturm?' CHECKED':'') +'>Wachturm Anzeigen! <SPAN class=boldRed>(Verteidigung/Versteckt)</span></td></tr>';
      str += '<TR><TD class=xtab></td><TD class=xtab colspan=8>Nahrung Verbrauch Anzeigen! | Oben <INPUT type=CHECKBOX id=ptIncNahrung'+ (Options.includeNahrung?' CHECKED':'') +'> Unten <INPUT type=CHECKBOX id=ptIncNahrungUnten'+ (Options.includeNahrungUnten?' CHECKED':'') +'></td></tr>';
      str += '<TR><TD class=xtab></td><TD class=xtab colspan=8><INPUT type=CHECKBOX id=ptIncRessis'+ (Options.includeRessis?' CHECKED':'') +'>Ressourcen Anzeigen!</td></tr>';
    str += '<TR><TD class=xtab></td><TD class=xtab colspan=8><INPUT type=CHECKBOX id=ptIncTruppen'+ (Options.includeTruppen?' CHECKED':'') +'>Truppen Anzeigen! | Auszubildene Truppen Anzeigen/Zusammenrechnen <INPUT type=CHECKBOX id=ptoverIncTraining'+ (Options.includeTraining?' CHECKED':'') +'></td></tr>';
      str += '<TR><TD class=xtab></td><TD class=xtab colspan=8><INPUT type=CHECKBOX id=ptIncInfos'+ (Options.includeInfos?' CHECKED':'') +'>Informationen Anzeigen! <SPAN class=boldRed>(Ritter, Wildnisse, Warte und Ausbildungsschalngen)</span></td></tr>';
      str += '<TR><TD class=xtab></td><TD class=xtab colspan=8><INPUT type=CHECKBOX id=ptOverOver'+ (Options.overviewAllowOverflow?' CHECKED':'') +'>Overflow erlauben <SPAN class=boldRed>(keine Scrollbalken!)</span> | Schriftgröße: '+ htmlSelector ({9:9, 10:10, 11:11, 12:12 , 14:14}, Options.overviewFontSize, 'id=ptoverfont') +'</td></tr>';
    str += '<TR><TD class=xtab></td><TD class=xtab colspan=8><INPUT type=CHECKBOX id=idCheck'+ (Options.includeMarching?' CHECKED':'') +'>Marschierende Truppen/Resourcen Anzeigen</td></tr>';
      str += "</table></div>";
      Tabs.Overview.cont.innerHTML = str;
    document.getElementById('ptIncRessis').addEventListener('click', e_clickEnableRessis, false);
    document.getElementById('ptIncInfos').addEventListener('click', e_clickEnableInfos, false);
    document.getElementById('ptIncWachturm').addEventListener('click', e_clickEnableWachturm, false);
    document.getElementById('ptIncNahrungUnten').addEventListener('click', e_clickEnableNahrungUnten, false);
    document.getElementById('ptIncNahrung').addEventListener('click', e_clickEnableNahrung, false);
      document.getElementById('idCheck').addEventListener('click', e_clickEnableMarch, false);
      document.getElementById('ptIncTruppen').addEventListener('click', e_clickEnableTruppen, false);
      document.getElementById('ptoverIncTraining').addEventListener('click', e_clickEnableTraining, false);
      document.getElementById('ptOverOver').addEventListener('click', e_allowWidthOverflow, false);
      document.getElementById('ptoverfont').addEventListener('change', e_fontSize, false);
//DebugTimer.display ('Draw Overview');    
    } catch (e){
      Tabs.Overview.cont.innerHTML = '<PRE>'+ e.name +' : '+ e.message +'</pre>';
    }   
    t.displayTimer = setTimeout (t.show, 5000);

    function e_clickEnableMarch (){
      var t = Tabs.Overview;
      Options.includeMarching = document.getElementById('idCheck').checked;
      t.show ();
    }
    function e_clickEnableTraining (){
      var t = Tabs.Overview;
      Options.includeTraining = document.getElementById('ptoverIncTraining').checked;
      t.show ();
    }
      function e_clickEnableTruppen (){
      var t = Tabs.Overview;
      Options.includeTruppen = document.getElementById('ptIncTruppen').checked;
      t.show ();
    }
    function e_clickEnableNahrung (){
      var t = Tabs.Overview;
      Options.includeNahrung = document.getElementById('ptIncNahrung').checked;
      t.show ();
    }
      function e_clickEnableNahrungUnten (){
      var t = Tabs.Overview;
      Options.includeNahrungUnten = document.getElementById('ptIncNahrungUnten').checked;
      t.show ();
    }
      function e_clickEnableWachturm (){
      var t = Tabs.Overview;
      Options.includeWachturm = document.getElementById('ptIncWachturm').checked;
      t.show ();
    }
      function e_clickEnableRessis (){
      var t = Tabs.Overview;
      Options.includeRessis = document.getElementById('ptIncRessis').checked;
      t.show ();
    }
      function e_clickEnableInfos (){
      var t = Tabs.Overview;
      Options.includeInfos = document.getElementById('ptIncInfos').checked;
      t.show ();
    }
    function e_fontSize(evt){
      document.getElementById('overMainDiv').style.fontSize = evt.target.value +'px';
      Options.overviewFontSize = evt.target.value;
    }

    function e_allowWidthOverflow (evt){
      var tf = document.getElementById('ptOverOver').checked;
      Options.overviewAllowOverflow = tf;
      if (tf)
        t.cont.style.overflowX = 'visible';
      else
        t.cont.style.overflowX = 'auto';
    }

  },
};


function getWallInfo (cityId, objOut){
  objOut.wallSpaceUsed = 0;
  objOut.fieldSpaceUsed = 0;
  objOut.wallLevel = 0;  
  objOut.wallSpace = 0;     
  objOut.fieldSpace = 0;  
  var b = Seed.buildings["city" + cityId];
  if (b.pos1==null)
    return;  
  objOut.wallLevel = parseInt(b.pos1[1]);
  var spots = 0;
  for (var i=1; i<(objOut.wallLevel+1); i++)
    spots += (i * 500);
  objOut.wallSpace = spots;     
  objOut.fieldSpace = spots;  
     
  var fort = Seed.fortifications["city" + cityId];
  for (k in fort){
    var id = parseInt(k.substr(4));
    if (id<60)
      objOut.wallSpaceUsed += parseInt(unsafeWindow.fortstats["unt"+ id][5]) * parseInt(fort[k]);
    else
      objOut.fieldSpaceUsed += parseInt(unsafeWindow.fortstats["unt"+ id][5]) * parseInt(fort[k]);
  }
}    
/*************************************** MARCHES TAB ************************************************/

Tabs.Marches = {
  tabLabel : 'Marsch',
  tabOrder : 5,
  cont:null,
  displayTimer:null,
  curTabBut : null,
  curTabName : null,
  
  init : function (div){
    var t = Tabs.Marches;
    unsafeWindow.pr56Recall = t.butRecall;
    unsafeWindow.r8x6Home = t.butSendHome;
    unsafeWindow.undefend = t.butundefend;
    unsafeWindow.cancelMarch = t.butcancelmarch;
    
    t.cont = div;
    t.cont.innerHTML = '<TABLE class=ptTab align=center><TR><TD><INPUT class=pbSubtab ID=ptmrchSubA type=submit value=Angriffe></td>\
          <TD><INPUT class=pbSubtab ID=ptmrchSubM type=submit value=Märsche></td>\
          <TD><INPUT class=pbSubtab ID=ptmrchSubR type=submit value=Verstärkung></td></tr></table><HR class=ptThin>\
      <DIV id=ptMarchOutput style="margin-top:10px; background-color:white; height:500px; max-width:740px; overflow:scroll;"></div>';
    t.marchDiv = document.getElementById('ptMarchOutput');
    document.getElementById('ptmrchSubA').addEventListener('click', e_butSubtab, false);
    document.getElementById('ptmrchSubR').addEventListener('click', e_butSubtab, false);
    document.getElementById('ptmrchSubM').addEventListener('click', e_butSubtab, false);
    changeSubtab (document.getElementById('ptmrchSub'+Options.curMarchTab));
    
    function e_butSubtab (evt){
      changeSubtab (evt.target);   
    }

    function changeSubtab (but){
      if (but == t.curTabBut)
        return;
      if (t.curTabBut){
        t.curTabBut.className='pbSubtab';
        t.curTabBut.disabled=false;
      }
      t.curTabBut = but;
      but.className='pbSubtab pbSubtabSel';
      but.disabled=true;
      t.curTabName = but.id.substr(9);
      Options.curMarchTab = t.curTabName;
      t.show ();
    }    
  },

  hide : function (){
    var t = Tabs.Marches;
    clearTimeout (t.displayTimer);
    mainPop.div.style.height = 750 + 'px';
  },
  
  show : function (){
    var t = Tabs.Marches;
    clearTimeout (t.displayTimer);
    if (t.curTabName == 'R')
      t.showReinforcements();
    else if (t.curTabName == 'M')
      t.showMarches();
    else
      t.showIncoming();
   mainPop.div.style.height = 500 + 'px';
  },
 
  
  /***   Incoming SUBTAB  ***/
      showIncoming : function (){
        var t = Tabs.Marches;
        t.marchDiv.innerHTML =null;  
        //var updatemarch = Seed.queue_atkinc;
        var icon;
        var status;
        var FROM;
        var cityname;
        var FROMmight;
        //var z = '<TD><INPUT id=TEST type=submit value="TEST"></td>';
        //z += '<TD><INPUT id=TEST2 type=submit value="TEST2"></td>';
         var z = '<TABLE id=pdincoming cellSpacing=10 width=100% height=0% class=pbTab>';
       
       for (k in Seed.queue_atkinc) {
          if(Seed.queue_atkinc.length !=0){
          // if  (parseInt(Seed.queue_atkinc[k]["marchType"]) ==3 || parseInt(Seed.queue_atkinc[k]["marchType"])==4){
                   now = unixTime();
                   var marchType = parseInt(Seed.queue_atkinc[k]["marchType"]);
                   var marchStatus = parseInt(Seed.queue_atkinc[k]["marchStatus"]);
                   
                   for (var i=0; i<Seed.cities.length;i++) {
                       if (Seed.cities[i][0] == Seed.queue_atkinc[k]["toCityId"]) cityname = Seed.cities[i][1];
                   }   
                       
                   if (Seed.queue_atkinc[k]["destinationUnixTime"] < (now) || marchStatus == 8) marchstatus = "returning";
                   else marchstatus = "going";  
                   
                   if (marchStatus == 2) destinationUnixTime = now - Seed.queue_atkinc[k]["arrivalTime"]; //- now;
                   if (marchStatus == 1) destinationUnixTime = Seed.queue_atkinc[k]["arrivalTime"] - now;
                   else  destinationUnixTime = Seed.queue_atkinc[k]["arrivalTime"] - now;
                   marchtime = timestr(destinationUnixTime, true)
                                      
                   if (marchType != 3 && marchType !=4){
                     for (players in Seed.players){
                       if (('u'+Seed.queue_atkinc[k]["fromPlayerId"]) == players){ FROM = Seed.players[players]["n"];}
                     }
                   }
                   else {
                   for (players in Seed.players){
                       if (marchType == 3 || marchType == 4){
                        if (('u'+Seed.queue_atkinc[k]["pid"]) == players){
                              FROM = Seed.players[players]["n"];
                              FROMmight = Seed.players[players]["m"];
                        }
                      }
                     }
                   }
                   
                   if (marchType == 2 && marchStatus == 2) marchType = 102;
                   
                   switch (marchType) {
                       case 1: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/transporting.jpg";status="Transport";break;
                       case 2: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/reinforce.jpg";status="Verstärken";break;
                       case 3: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/scouting.jpg";status="Späher";break;
                       case 4: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/attacking.jpg";status="Angriff";break;
                       case 5: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/transporting.jpg";status="Neu zuordnen";break;
                       case 100: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/returning.jpg";status="Rückmarsch";break;
                       case 102: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/reinforce.jpg";status="Lagernd";break;
                   }
                   
                   z += '<TD width="10px"><img src='+ icon +'></td>';
                   z += '<TD width="40px">'+ status +'</td>';
                   z += '<TD><u>' + cityname + '</u></td>';
                   z += '<TD>'+ marchtime +'</td>';
                   z +='<TD>von:' + FROM + '</td>';
                   z +='<TD>Macht:' + addCommas(FROMmight) + '</td>';
                   if (Seed.queue_atkinc[k]["knt"] != undefined) z +='<TD>Ritter:'+ Seed.queue_atkinc[k]["knt"]["cbt"]+'</td>';
                    //alert(Seed.queue_atkinc.toSource());
                   //if (Seed.queue_atkinc[k]["knightId"] !=0) z +='<TD>Knight:' + Seed.queue_atkinc[k]["knightCombat"] + '</td>';
                   
                 if (Seed.queue_atkinc[k]["gold"] > 0) z += '<TD>Gold:'+ addCommas(Seed.queue_atkinc[k]["gold"]) +'</td>';
                 if (Seed.queue_atkinc[k]["resource1"] > 0) z += '<TD>Nahrung: '+ addCommas(Seed.queue_atkinc[k]["resource1"]) +'</td>';
                 if (Seed.queue_atkinc[k]["resource2"] > 0) z += '<TD>Holz: '+ addCommas(Seed.queue_atkinc[k]["resource2"]) +'</td>';
                if (Seed.queue_atkinc[k]["resource3"] > 0) z += '<TD>Stein: '+ addCommas(Seed.queue_atkinc[k]["resource3"]) +'</td>';
                if (Seed.queue_atkinc[k]["resource4"] > 0) z += '<TD>Erz: '+ addCommas(Seed.queue_atkinc[k]["resource4"]) +'</td>';
                
                if (Seed.queue_atkinc[k]["unit0Count"] > 0 && marchstatus == "going") z += '<TD???'+ addCommas(Seed.queue_atkinc[k]["unit0Count"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit0Return"] > 0 && marchstatus == "returning") z += '<TD>???: '+ addCommas(Seed.queue_atkinc[k]["unit0Return"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit1Count"] > 0 && marchstatus == "going") z += '<TD>Versorger: '+ addCommas(Seed.queue_atkinc[k]["unit1Count"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit1Return"] > 0 && marchstatus == "returning") z += '<TD>Versorger: '+ addCommas(Seed.queue_atkinc[k]["unit1Return"]) +'</td>';
                
                if (Seed.queue_atkinc[k]["unit2Count"] > 0 && marchstatus == "going") z += '<TD>Miliz: '+ addCommas(Seed.queue_atkinc[k]["unit2Count"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit2Return"] > 0 && marchstatus == "returning") z += '<TD>Miliz: '+ addCommas(Seed.queue_atkinc[k]["unit2Return"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit3Count"] > 0 && marchstatus =="going") z += '<TD>Späher: '+ addCommas(Seed.queue_atkinc[k]["unit3Count"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit3Return"] > 0 && marchstatus == "returning") z += '<TD>Späher: '+ addCommas(Seed.queue_atkinc[k]["unit3Return"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit4Count"] > 0 && marchstatus =="going") z += '<TD>Lanzen: '+ addCommas(Seed.queue_atkinc[k]["unit4Count"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit4Return"] > 0 && marchstatus == "returning") z += '<TD>Lanzen: '+ addCommas(Seed.queue_atkinc[k]["unit4Return"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit5Count"] > 0 && marchstatus =="going") z += '<TD>Schwerter: '+ addCommas(Seed.queue_atkinc[k]["unit5Count"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit5Return"] > 0 && marchstatus == "returning") z += '<TD>Schwerter: '+ addCommas(Seed.queue_atkinc[k]["unit5Return"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit6Count"] > 0 && marchstatus =="going") z += '<TD>Bogen: '+ addCommas(Seed.queue_atkinc[k]["unit6Count"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit6Return"] > 0 && marchstatus == "returning") z += '<TD>Bogen: '+ addCommas(Seed.queue_atkinc[k]["unit6Return"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit7Count"] > 0 && marchstatus =="going") z += '<TD>Kav: '+ addCommas(Seed.queue_atkinc[k]["unit7Count"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit7Return"] > 0 && marchstatus == "returning") z += '<TD>Kav: '+ addCommas(Seed.queue_atkinc[k]["unit7Return"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit8Count"] > 0 && marchstatus =="going") z += '<TD>S-Kav: '+ addCommas(Seed.queue_atkinc[k]["unit8Count"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit8Return"] > 0 && marchstatus == "returning") z += '<TD>S-Kav: '+ addCommas(Seed.queue_atkinc[k]["unit8Return"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit9Count"] > 0 && marchstatus =="going") z += '<TD>Versorgungswagen: '+ addCommas(Seed.queue_atkinc[k]["unit9Count"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit9Return"] > 0 && marchstatus == "returning") z += '<TD>Versorgungswagen: '+ addCommas(Seed.queue_atkinc[k]["unit9Return"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit10Count"] > 0 && marchstatus =="going") z += '<TD>Ballisten: '+ addCommas(Seed.queue_atkinc[k]["unit10Count"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit10Return"] > 0 && marchstatus == "returning") z += '<TD>Ballisten: '+ addCommas(Seed.queue_atkinc[k]["unit10Return"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit11Count"] > 0 && marchstatus =="going") z += '<TD>Ramm: '+ addCommas(Seed.queue_atkinc[k]["unit11Count"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit11Return"] > 0 && marchstatus == "returning") z += '<TD>Ramm: '+ addCommas(Seed.queue_atkinc[k]["unit11Return"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit12Count"] > 0 && marchstatus =="going") z += '<TD>Steinschleuder: '+ addCommas(Seed.queue_atkinc[k]["unit12Count"]) +'</td>';
                if (Seed.queue_atkinc[k]["unit12Return"] > 0 && marchstatus == "returning") z += '<TD>Steinschleuder: '+ addCommas(Seed.queue_atkinc[k]["unit12Return"]) +'</td>';
                
                if (marchType == 3 && Seed.queue_atkinc[k]["unts"]["u3"] > 0) z += '<TD>Späher: '+ addCommas(Seed.queue_atkinc[k]["unts"]["u3"]) +'</td>';
                if (marchType == 4 && Seed.queue_atkinc[k]["unts"]["u1"] > 0) z += '<TD>Versorger: '+ addCommas(Seed.queue_atkinc[k]["unts"]["u1"]) +'</td>';
                   if (marchType == 4 && Seed.queue_atkinc[k]["unts"]["u2"] > 0) z += '<TD>Miliz: '+ addCommas(Seed.queue_atkinc[k]["unts"]["u2"]) +'</td>';
                   if (marchType == 4 && Seed.queue_atkinc[k]["unts"]["u3"] > 0) z += '<TD>Späher: '+ addCommas(Seed.queue_atkinc[k]["unts"]["u3"]) +'</td>';
                   if (marchType == 4 && Seed.queue_atkinc[k]["unts"]["u4"] > 0) z += '<TD>Lanzen: '+ addCommas(Seed.queue_atkinc[k]["unts"]["u4"]) +'</td>';
                   if (marchType == 4 && Seed.queue_atkinc[k]["unts"]["u5"] > 0) z += '<TD>Schwerter: '+ addCommas(Seed.queue_atkinc[k]["unts"]["u5"]) +'</td>';
                   if (marchType == 4 && Seed.queue_atkinc[k]["unts"]["u6"] > 0) z += '<TD>Bogen: '+ addCommas(Seed.queue_atkinc[k]["unts"]["u6"]) +'</td>';
                   if (marchType == 4 && Seed.queue_atkinc[k]["unts"]["u7"] > 0) z += '<TD>Kav: '+ addCommas(Seed.queue_atkinc[k]["unts"]["u7"]) +'</td>';
                   if (marchType == 4 && Seed.queue_atkinc[k]["unts"]["u8"] > 0) z += '<TD>S-Kav: '+ addCommas(Seed.queue_atkinc[k]["unts"]["u8"]) +'</td>';
                   if (marchType == 4 && Seed.queue_atkinc[k]["unts"]["u9"] > 0) z += '<TD>Versorgungswagen: '+ addCommas(Seed.queue_atkinc[k]["unts"]["u9"]) +'</td>';
                   if (marchType == 4 && Seed.queue_atkinc[k]["unts"]["u10"] > 0) z += '<TD>Ballisten: '+ addCommas(Seed.queue_atkinc[k]["unts"]["u10"]) +'</td>';
                   if (marchType == 4 && Seed.queue_atkinc[k]["unts"]["u11"] > 0) z += '<TD>Ramm: '+ addCommas(Seed.queue_atkinc[k]["unts"]["u11"]) +'</td>';
                   if (marchType == 4 && Seed.queue_atkinc[k]["unts"]["u12"] > 0) z += '<TD>Steinschleuder: '+ addCommas(Seed.queue_atkinc[k]["unts"]["u12"]) +'</td>';
                   z += '</tr>';
              }
         }
   //  }
     z += '</table>';
     t.marchDiv.innerHTML = z;
               
     t.displayTimer = setTimeout (t.showIncoming, 500);  
   },   
      
        
  /***   MARCHES SUBTAB  ***/
    showMarches : function (){
      var t = Tabs.Marches;
      t.marchDiv.innerHTML =null;  
      var updatemarch = Seed.queue_atkp;
      var icon;
      var status;
      var number = 0;
     
     var  m = '<TABLE id=pdmarches cellSpacing=10 width=100% height=0% class=pbTab>';
          
     for (var c=0; c< Seed.cities.length;c++) {
         cityname = Seed.cities[c][1];
         cityID = 'city' + Seed.cities[c][0];
         var cityTo;    
        number=0;  
        
        if (Seed.queue_atkp[cityID].length !=0) m+= '<TR><TD style=\'background: #99CCFF;\' align=center><B><u>' + cityname +' </u></b></td></tr>';
          for (k in Seed.queue_atkp[cityID]){
           if (Seed.queue_atkp[cityID].length !=0) {
              var marchID = new String(k);
              marchID = marchID.substr(1);
              var marchType = parseInt(Seed.queue_atkp[cityID][k]["marchType"]);
              var marchStatus = parseInt(Seed.queue_atkp[cityID][k]["marchStatus"]);
              now = unixTime();
              number++;
              cityTo=null;
              var knight=null;
              
              for (var i=0; i<Seed.cities.length;i++) {
                  if (Seed.cities[i][2] == Seed.queue_atkp[cityID][k]["toXCoord"] && Seed.cities[i][3] == Seed.queue_atkp[cityID][k]["toYCoord"]) cityTo = Seed.cities[i][1];
                  
              }
              
              destinationUnixTime = Seed.queue_atkp[cityID][k]["destinationUnixTime"] - now;
              returnUnixTime = Seed.queue_atkp[cityID][k]["returnUnixTime"] - now;
              encampedUnixTime = now - Seed.queue_atkp[cityID][k]["destinationUnixTime"];
              if (Seed.queue_atkp[cityID][k]["destinationUnixTime"] > now) marchtime = timestr(destinationUnixTime, true);
              else  marchtime = timestr(returnUnixTime, true);
              
              if (Seed.queue_atkp[cityID][k]["destinationUnixTime"] < (now) && marchType == 2) marchtime = timestr(encampedUnixTime, true);
            
              if (Seed.queue_atkp[cityID][k]["destinationUnixTime"] < (now) || marchStatus == 8) marchstatus = "returning";
              else marchstatus = "going";
             
              if (marchstatus =="returning" && marchType == 2 && Seed.queue_atkp[cityID][k]["destinationUnixTime"] < (now) && marchStatus != 2) marchtime = timestr(returnUnixTime, true);
              if (marchstatus =="returning" && marchType == 4 && Seed.queue_atkp[cityID][k]["destinationUnixTime"] < (now) && marchStatus == 2) marchtime = timestr(returnUnixTime, true);
              if (marchStatus == 2 && Seed.queue_atkp[cityID][k]["destinationUnixTime"] < (now) && marchType !=2) marchtime = timestr(returnUnixTime, true);
              if (marchStatus == 8 && Seed.queue_atkp[cityID][k]["destinationUnixTime"] < (now)) marchtime = timestr(returnUnixTime, true);
              if (parseInt(Seed.queue_atkp[cityID][k]["marchType"]) == 4 && marchStatus == 2) marchtime = timestr(destinationUnixTime, true);;
              
              
              if (marchstatus =="returning" && marchType != 2) marchType = 100;
              if (marchstatus =="returning" && marchType == 2 && marchStatus == 2) marchType = 102;
              
              if (marchstatus =="returning" && marchType == 2 && Seed.queue_atkp[cityID][k]["destinationUnixTime"] < (now) && marchStatus != 2) marchType = 100;
              
              if (parseInt(Seed.queue_atkp[cityID][k]["marchType"]) == 4 && marchStatus == 2) {
              marchType = 102;
              marchtime = timestr(encampedUnixTime, true)
              }
  
              switch (marchType) {
                case 1: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/transporting.jpg";status="Transport";break;
                case 2: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/reinforce.jpg";status="Verstärken";break;
                case 3: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/scouting.jpg";status="Ausspähen";break;
                case 4: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/attacking.jpg";status="Angriff";break;
                case 5: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/transporting.jpg";status="Neu zuordnen";break;
                case 100: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/returning.jpg";status="Rückmarsch";break;
                case 102: icon="http://cdn1.kingdomsofcamelot.com/fb/e2/src/img/reinforce.jpg";status="Lagernd";break;
              }
                            
              if (Seed.queue_atkp[cityID][k]["knightId"] !=0){
                for (i in Seed.knights[cityID]) {
                    if (i == ("knt" + Seed.queue_atkp[cityID][k]["knightId"]) ) knight = Seed.knights[cityID][i]["combat"];
                }
              } else knight = null;
                            
              if (status=="Lagernd") m += '<TR><TD width="5px"><A><SPAN onclick="undefend('+ marchID +')">X</span></a></td>'
              else m += '<TR><TD width="5px"><A><SPAN onclick="cancelMarch('+ marchID +')">X</span></a></td>'
              m += '<TD>'+ number +'</td>';
              m += '<TD width="10px"><img src='+ icon +'></td>';
              m += '<TD width="40px">'+ status +'</td>';
              m += '<TD>'+ marchtime +'</td>';
              
              if (cityTo == null) m += '<TD style="padding-right:10px;">'+ Seed.queue_atkp[cityID][k]["toXCoord"] + ',' + Seed.queue_atkp[cityID][k]["toYCoord"] + '</td>';
              else m += '<TD style="padding-right:10px;">'+ cityTo +'</td>';
              
              if (knight != null)  m += '<TD>Ritter: '+ knight +'</td>';
              
              if (Seed.queue_atkp[cityID][k]["toTileType"] == 11) m+='<TD>See Lvl: ' + Seed.queue_atkp[cityID][k]["toTileLevel"] + '</td>';
              else if (Seed.queue_atkp[cityID][k]["toTileType"] == 20) m+='<TD>Grassland Lvl: ' + Seed.queue_atkp[cityID][k]["toTileLevel"] + '</td>';
              else if (Seed.queue_atkp[cityID][k]["toTileType"] == 30) m+='<TD>Hügel Lvl: ' + Seed.queue_atkp[cityID][k]["toTileLevel"] + '</td>';
              else if (Seed.queue_atkp[cityID][k]["toTileType"] == 40) m+='<TD>Berg Lvl: ' + Seed.queue_atkp[cityID][k]["toTileLevel"] + '</td>';
              else if (Seed.queue_atkp[cityID][k]["toTileType"] == 50) m+='<TD>Ebene Lvl: ' + Seed.queue_atkp[cityID][k]["toTileLevel"] + '</td>';
            else if (Seed.queue_atkp[cityID][k]["toCityId"] ==0) m +='<TD>Barbaren Lvl: '+Seed.queue_atkp[cityID][k]["toTileLevel"]+'</td>';
      
              if (Seed.queue_atkp[cityID][k]["gold"] > 0) m += '<TD>Gold:'+ Seed.queue_atkp[cityID][k]["gold"] +'</td>';
              if (Seed.queue_atkp[cityID][k]["resource1"] > 0) m += '<TD>Nahrung: '+ addCommas(Seed.queue_atkp[cityID][k]["resource1"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["resource2"] > 0) m += '<TD>Holz: '+ addCommas(Seed.queue_atkp[cityID][k]["resource2"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["resource3"] > 0) m += '<TD>Stein: '+ addCommas(Seed.queue_atkp[cityID][k]["resource3"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["resource4"] > 0) m += '<TD>Erz: '+ addCommas(Seed.queue_atkp[cityID][k]["resource4"]) +'</td>';
              
              if (Seed.queue_atkp[cityID][k]["unit0Count"] > 0 && marchstatus == "going") m += '<TD???'+ addCommas(Seed.queue_atkp[cityID][k]["unit0Count"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit0Return"] > 0 && marchstatus == "returning") m += '<TD>???: '+ addCommas(Seed.queue_atkp[cityID][k]["unit0Return"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit1Count"] > 0 && marchstatus == "going") m += '<TD>Versorger: '+ addCommas(Seed.queue_atkp[cityID][k]["unit1Count"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit1Return"] > 0 && marchstatus == "returning") m += '<TD>Versorger: '+ addCommas(Seed.queue_atkp[cityID][k]["unit1Return"]) +'</td>';
              
              if (Seed.queue_atkp[cityID][k]["unit2Count"] > 0 && marchstatus == "going") m += '<TD>Miliz: '+ addCommas(Seed.queue_atkp[cityID][k]["unit2Count"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit2Return"] > 0 && marchstatus == "returning") m += '<TD>Miliz: '+ addCommas(Seed.queue_atkp[cityID][k]["unit2Return"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit3Count"] > 0 && marchstatus =="going") m += '<TD>Späher: '+ addCommas(Seed.queue_atkp[cityID][k]["unit3Count"])+'</td>';
              if (Seed.queue_atkp[cityID][k]["unit3Return"] > 0 && marchstatus == "returning") m += '<TD>Späher: '+ addCommas(Seed.queue_atkp[cityID][k]["unit3Return"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit4Count"] > 0 && marchstatus =="going") m += '<TD>Lanzen: '+ addCommas(Seed.queue_atkp[cityID][k]["unit4Count"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit4Return"] > 0 && marchstatus == "returning") m += '<TD>Lanzen: '+ addCommas(Seed.queue_atkp[cityID][k]["unit4Return"])+'</td>';
              if (Seed.queue_atkp[cityID][k]["unit5Count"] > 0 && marchstatus =="going") m += '<TD>Schwerter: '+ addCommas(Seed.queue_atkp[cityID][k]["unit5Count"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit5Return"] > 0 && marchstatus == "returning") m += '<TD>Schwerter: '+ addCommas(Seed.queue_atkp[cityID][k]["unit5Return"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit6Count"] > 0 && marchstatus =="going") m += '<TD>Bogen: '+ addCommas(Seed.queue_atkp[cityID][k]["unit6Count"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit6Return"] > 0 && marchstatus == "returning") m += '<TD>Bogen: '+ addCommas(Seed.queue_atkp[cityID][k]["unit6Return"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit7Count"] > 0 && marchstatus =="going") m += '<TD>Kav: '+ addCommas(Seed.queue_atkp[cityID][k]["unit7Count"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit7Return"] > 0 && marchstatus == "returning") m += '<TD>Kav: '+ addCommas(Seed.queue_atkp[cityID][k]["unit7Return"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit8Count"] > 0 && marchstatus =="going") m += '<TD>S-Kav: '+ addCommas(Seed.queue_atkp[cityID][k]["unit8Count"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit8Return"] > 0 && marchstatus == "returning") m += '<TD>S-Kav: '+ addCommas(Seed.queue_atkp[cityID][k]["unit8Return"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit9Count"] > 0 && marchstatus =="going") m += '<TD>Versorgungswagen: '+ addCommas(Seed.queue_atkp[cityID][k]["unit9Count"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit9Return"] > 0 && marchstatus == "returning") m += '<TD>Versorgungswagen: '+ addCommas(Seed.queue_atkp[cityID][k]["unit9Return"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit10Count"] > 0 && marchstatus =="going") m += '<TD>Ballisten: '+ addCommas(Seed.queue_atkp[cityID][k]["unit10Count"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit10Return"] > 0 && marchstatus == "returning") m += '<TD>Ballisten: '+ addCommas(Seed.queue_atkp[cityID][k]["unit10Return"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit11Count"] > 0 && marchstatus =="going") m += '<TD>Ramm: '+ addCommas(Seed.queue_atkp[cityID][k]["unit11Count"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit11Return"] > 0 && marchstatus == "returning") m += '<TD>Ram: '+ addCommas(Seed.queue_atkp[cityID][k]["unit11Return"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit12Count"] > 0 && marchstatus =="going") m += '<TD>Steinschleuder: '+ addCommas(Seed.queue_atkp[cityID][k]["unit12Count"]) +'</td>';
              if (Seed.queue_atkp[cityID][k]["unit12Return"] > 0 && marchstatus == "returning") m += '<TD>Steinschleuder﻿: '+ addCommas(Seed.queue_atkp[cityID][k]["unit12Return"]) +'</td></tr>';
           }
          }
         
    }
    m += '</table>';
    t.marchDiv.innerHTML = m;
 	document.getElementById('TEST').addEventListener('click', function(){
		
		var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
  			new AjaxRequest(unsafeWindow.g_ajaxpath + "/fb/e2/src/main_src.php?g=&y=0&n=nan001&l=nl_NL&messagebox=&standalone=0&res=1&iframe=1&lang=en&ts=1304248288.7067&s=250&appBar=" + unsafeWindow.g_ajaxsuffix, {
  			    method: "POST",
  			    parameters: params,
  			    onSuccess: function (rslt) {
  			        //rslt = eval("(" + message + ")");
  			        var mainSrcHTMLCode = rslt.responseText;
  			    	//var mainSrcHTMLCode; // get and set this by pulling in the main_src.php file via AJAX
  			    	var myregexp = /var seed=\{.*?\};/;
  			    	var match = myregexp.exec(mainSrcHTMLCode);
  			    	
  			    	if (match != null) {
  			    	result = match[0];
  			    	result = result.substr(4);
  			    	var seed;
  			    	eval(result);
	  			    alert(seed.toSource());
	  			    unsafeWindow.document.seed = seed;
  			    	}
  			    },
  			    onFailure: function () {
  			      if (notify != null)
  			        notify(rslt.errorMsg);
  			    },
  			});
	
  	}, false);
	     
    t.displayTimer = setTimeout (t.showMarches, 500);  
    },
    
    butcancelmarch: function(marchID){
       var t = Tabs.Marches;
          var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
          params.mid = marchID;
           for (var c=0; c<Cities.numCities; c++){
            var que = Seed.queue_atkp['city'+ Cities.cities[c].id];
            if (matTypeof(que)=='array')
              continue;
            for (k in que){
              if (k == 'm'+marchID){
                params.cid = Cities.cities[c].id;
                break;
              }
            }    
          }    
          
          new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/cancelMarch.php" + unsafeWindow.g_ajaxsuffix, {
              method: "post",
              parameters: params,
              onSuccess: function (rslt) {
              var march = unsafeWindow.seed.queue_atkp["city" + params.cid]["m" + params.mid];
              march.marchStatus = 8;
               var marchtime = parseInt(march.returnUnixTime) - parseInt(march.destinationUnixTime);
               var ut = unixTime();
               if (unsafeWindow.seed.playerEffects.returnExpire > unixtime())
                 marchtime *= 0.5
                march.returnUnixTime = ut + marchtime;
                march.destinationUnixTime = ut;
                march.marchUnixTime = ut - marchtime;
                if (notify != null)
                  notify(rslt.errorMsg);
              },
              onFailure: function () {
                if (notify != null)
                  notify(rslt.errorMsg);
              },
          });
          
       },
    
    butundefend: function(marchID){
       var t = Tabs.Marches;
       var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
       params.mid = marchID;
       for (var c=0; c<Cities.numCities; c++){
         var que = Seed.queue_atkp['city'+ Cities.cities[c].id];
         if (matTypeof(que)=='array')
           continue;
         for (k in que){
           if (k == 'm'+marchID){
             params.cid = Cities.cities[c].id;
             break;
           }
         }    
       }    
       
       
       new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/undefend.php" + unsafeWindow.g_ajaxsuffix, {
           method: "post",
           parameters: params,
           onSuccess: function (rslt) {
             var march = unsafeWindow.seed.queue_atkp["city" + params.cid]["m" + params.mid];
             march.marchStatus = 8;
             var marchtime = parseInt(march.returnUnixTime) - parseInt(march.destinationUnixTime);
             var ut = unixTime();
             if (unsafeWindow.seed.playerEffects.returnExpire > unixtime())
               marchtime *= 0.5
             march.returnUnixTime = marchtime;
             march.destinationUnixTime = ut;
             march.marchUnixTime = ut - marchtime;
             if (notify != null)
               notify(rslt.errorMsg);
           },
           onFailure: function () {
             if (notify != null)
               notify(rslt.errorMsg);
           },
       });
    },
    
      
   /***  REINFORCEMENTS SUBTAB  ***/
  showReinforcements : function (){
    var rownum = 0;
    var names = ['Versorger', 'Miliz', 'Späher', 'Lanzen', 'Schwerter', 'Bogen', 'Kav', 'S-Kav', 'Wagen', 'Ballisten', 'Ram', 'Kat'];
    var t = Tabs.Marches;
    clearTimeout (t.displayTimer);

    
    
// TODO FIX:    Troops show as encamped even if they are here yet (check destinationUnixTime)
        


/***    
var s = 'OUTGOING:<BR>';
for (var c=0; c<Cities.numCities; c++){
  var que = Seed.queue_atkp['city'+ Cities.cities[c].id];
  if (matTypeof(que)=='array')
    continue;

s += 'City: '+  Cities.cities[c].name + ': <BR>';

  for (k in que){
    march = que[k];
    var mid = k.substr(1);
    s += mid +' DEST: '+ march.toXCoord +','+ march.toYCoord + '  <INPUT type=submit value="Recall" onclick="pr56Recall('+ mid +')"><BR>'
  }      
}
t.cont.innerHTML = s;
t.displayTimer = setTimeout (t.show, 10000);
return;
***/
    
    function clickShowRemaining (){
      checkBox = document.getElementById('idCheck2');
      if (checkBox.checked)
        Options.encRemaining = false;
      else
        Options.encRemaining = true;
      t.show ();
    }

        
    enc = {};
    numSlots = 0;
    
    
    if (matTypeof(Seed.queue_atkinc) != 'array'){
      for (k in Seed.queue_atkinc){
        march = Seed.queue_atkinc[k];
        if (march.marchType == 2){
          ++numSlots;
          city = march.toCityId;
          from = march.fromPlayerId;
          if (!enc[city])
            enc[city] = {};
          if (!enc[city][from])
            enc[city][from] = [];
          s = {};
          s.knight = parseInt (march.knightCombat);
          s.marchId = k.substr(1);
          s.troops = [];
          for (i=1; i<13; i++){
            if (Options.encRemaining)
              s.troops[i] = parseInt (march['unit'+ i +'Return']);
            else

              s.troops[i] = parseInt (march['unit'+ i +'Count']);
          }
          enc[city][from].push (s);
        }
      }
    }
//logit ("enc: "+ inspect (enc, 6, 1));    
    
    
    
    
    
    s = '<div class=ptstat>Truppen in deiner Botschaft</div><BR>';
    if (numSlots == 0){
      s += '<BR><CENTER><B>Es hat dir keiner verstärkung geschickt...! :/</b></center>';
    } else {
      s += '<STYLE> .tot{background:#f0e0f8;} .city{background:#ffffaa;}</style>';
      s += '<TABLE cellspacing=0 width=100%><TR align=right><TD align=left width=16%><B>Spieler (Ritterpunkte)</b></td>';

      for (k=0; k<names.length; k++)
        s += '<TD width=7%><B>' + names[k] + '</b></td>';
      s += '</tr>';

      tot = [];
      for (i=0; i<13; i++)
        tot[i] = 0;
      for (c in Cities.cities){
        dest = Cities.cities[c].id;
        if (enc[dest]){
          s+= '<TR><TD class=xtab><BR></td></tr>';
          s+= '<TR><TD class="city" colspan=13 align=center><B>'+ Cities.cities[c].name +'</b></td></tr>';
          for (p in enc[dest]){
            try {
              player = Seed.players['u'+p].n;
            } catch (err){
              player = '???';
            }
            for (m=0; m<enc[dest][p].length; m++){
              var march = enc[dest][p][m];
              knight = '';
              if (march.knight > 0)
                knight = ' ('+ march.knight +')';
// TODO: Only allow 'send home' if troops are here now  (marchStatus = ?)              
              s += '<TR align=right><TD align=left>'+ player + knight +' <A><SPAN onclick="r8x6Home('+ march.marchId +')">Zurückrufen</span></a></td>'
              for (i=1; i<13; i++){
                s += '<TD>'+ march.troops[i]  +'</td>';
                tot[i] += march.troops[i];
              }
              s += '</tr>';

            }
          }
        }
      }
      s += '<TR><TD colspan=13><BR><BR></td></tr><TR align=right><TD class="tot" align=left><B>Gesamt:</b></td>';
      for (i=1; i<13; i++)
        s+= '<TD class="tot">'+ tot[i] +'</td>';
      s += '</tr></table>';
    }

    s += '<BR><BR><INPUT type=CHECKBOX id=idCheck2 '+ (Options.encRemaining?'':' CHECKED ') +'> Truppen Anzeigen!';
    s += '<BR><BR><DIV style="font-size: 10px">Hinweis: Truppen werden erst nach Refresh Angezeigt! kein auto Refresh, also immer F5!</div>';
    t.marchDiv.innerHTML = s;
    checkBox = document.getElementById('idCheck2');
    checkBox.addEventListener('click', clickShowRemaining, false);
    t.displayTimer = setTimeout (t.show, 10000);
  },

  
  butRecall : function (marchId){
    var t = Tabs.Marches;
    logit ("CANCELLING: "+ marchId);
    t.ajaxRecall (marchId);
  },

  butSendHome : function (marchId){
    var t = Tabs.Marches;
    logit ("SEND HOME: "+ marchId);
    t.ajaxSendHome (marchId, function(r){t.show(); logit("AJAX RESULT: "+ r)});
  },


  /***  
  // not working, returns 'invalid parameters' :(  
  ajaxCancelMarch : function (marchId, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
logit ('ajaxCancelMarch: '+ marchId);    
    for (var c=0; c<Cities.numCities; c++){
      var que = Seed.queue_atkp['city'+ Cities.cities[c].id];
      if (matTypeof(que)=='array')
        continue;
      for (k in que){
        if (k == 'm'+marchId){
          params.cid = Cities.cities[c].id;
          params.cityId = Cities.cities[c].id;
          break;
        }
      }    
    }    
    params.marchId = marchId;
    params.mid = 'm'+ marchId;
    params.requestType = "CANCEL_MARCH";
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/cancelMarch.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        onSuccess: function (rslt) {
          if (notify != null)
            notify(rslt.errorMsg);
        },
        onFailure: function () {
          if (notify != null)
            notify(rslt.errorMsg);
        },
    });
  },
***/  
 




  ajaxSendHome : function (marchId, notify){
logit ('ajaxSendHome: '+ marchId);    
    var march = Seed.queue_atkinc['m'+ marchId];
    if (march == null){
      notify ('March not found!');
      return;
    }    
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    params.mid = marchId;
    params.cid = march.toCityId;
    params.fromUid = march.fromPlayerId;
    params.fromCid = march.fromCityId;
   
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/kickoutReinforcements.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        onSuccess: function (rslt) {
          if (rslt.ok){
            var upkeep = 0;
            for (var i=1; i<13; i++)
              upkeep += parseInt(march["unit" + i + "Return"]) * parseInt(unsafeWindow.unitupkeeps[i])
            unsafeWindow.seed.resources["city"+ march.toCityId].rec1[3] -= upkeep;
            if (parseInt(march.fromPlayerId) == parseInt(unsafeWindow.tvuid)) {
logit ('FROM ME!');
              var mymarch = unsafeWindow.seed.queue_atkp["city" + march.fromCityId]["m" + marchId];
              var marchtime = Math.abs(parseInt(mymarch.destinationUnixTime) - parseInt(mymarch.eventUnixTime));
              mymarch.returnUnixTime = unixTime() + marchtime;
              mymarch.marchStatus = 8;
            }
            delete unsafeWindow.seed.queue_atkinc["m" + marchId];
            if (notify != null)
              notify(null);
          } else {
            if (notify != null)
              notify(rslt.errorMsg);
          }
        },
        onFailure: function () {
          if (notify != null)
            notify(rslt.errorMsg);
        },
    });
  },

/*****

      for (var b = 1; b < 13; b++) {
        g += parseInt(e["unit" + b + "Return"]) * parseInt(unitupkeeps[b])
      }

function kickout_allies(mid, cid, fromUid, fromCid, upkeep) {
  var params = Object.clone(g_ajaxparams);
  params.mid = mid;
  params.cid = cid;
  params.fromUid = fromUid;
  params.fromCid = fromCid;
  new Ajax.Request(g_ajaxpath + "ajax/kickoutReinforcements.php" + g_ajaxsuffix, {
    method: "post",
    parameters: params,
    onSuccess: function(transport) {
      var rslt = eval("(" + transport.responseText + ")");
      if (rslt.ok) {
        Modal.showAlert(g_js_strings.kickout_allies.troopshome);
        seed.resources["city" + currentcityid].rec1[3] = parseInt(seed.resources["city" + currentcityid].rec1[3]) - upkeep;
        Modal.hideModalAll();
        if (parseInt(fromUid) == parseInt(tvuid)) {
          var curmarch = seed.queue_atkp["city" + fromCid]["m" + mid];
          var marchtime = Math.abs(parseInt(curmarch.destinationUnixTime) - parseInt(curmarch.eventUnixTime));
          curmarch.returnUnixTime = unixtime() + marchtime;
          curmarch.marchStatus = 8
        }
        delete seed.queue_atkinc["m" + mid]
      } else {
        Modal.showAlert(printLocalError((rslt.error_code || null), (rslt.msg || null), (rslt.feedback || null)))
      }
    },
    onFailure: function() {}
  })
};
***/




 
  ajaxRecall : function (marchId, notify){
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    for (var c=0; c<Cities.numCities; c++){
      var que = Seed.queue_atkp['city'+ Cities.cities[c].id];
      if (matTypeof(que)=='array')
        continue;
      for (k in que){
        if (k == 'm'+marchId){
          params.cid = Cities.cities[c].id;
          break;
        }
      }    
    }    
    params.mid = marchId;
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/undefend.php" + unsafeWindow.g_ajaxsuffix, {
        method: "post",
        parameters: params,
        onSuccess: function (rslt) {
          var march = unsafeWindow.seed.queue_atkp["city" + params.cid]["m" + params.mid];
          march.marchStatus = 8;
          var marchtime = parseInt(march.returnUnixTime) - parseInt(march.destinationUnixTime);
          var ut = unixTime();
          if (unsafeWindow.seed.playerEffects.returnExpire > unixtime())
            marchtime *= 0.5
          march.returnUnixTime = ut + marchtime;
          march.destinationUnixTime = ut;
          march.marchUnixTime = ut - marchtime;
          if (notify != null)
            notify(rslt.errorMsg);
        },
        onFailure: function () {
          if (notify != null)
            notify(rslt.errorMsg);
        },
    });
  },
  
};
/*******************************************/

var PageNavigator = {
  modalMessagesFunc : null,
  ctrlPaginationOld : null,
  loadPage_paginationOld : null,
  cpPager : null,
  
  init : function (){
    var t = PageNavigator;
    t.modalMessagesFunc = new CalterUwFunc ('modal_messages', [
        [/pageNavigatorModel =.*$/im, 'var pager = new ptPagerHook(0,5); pageNavigatorModel=pager'],
        [/pageNavigatorView =.*$/im, 'pageNavigatorView=pager'],
        [/pageNavigatorController =.*$/im, 'pageNavigatorController=pager']
        ]);
    unsafeWindow.ptPagerHook = t.Cpager;
    t.ctrlPaginationOld = unsafeWindow.ctrlPagination;
    t.loadPage_paginationOld = unsafeWindow.loadPage_pagination;
    t.cpPager = new t.Cpager (0,0);
    t.cpPager.oldStyle = true;
    t.enable(Options.fixPageNav);
  },

  // called on 'back' ...
  loadPage_pagination : function (divId, currentPage, callbackFunction, totalPages) {
    var t = PageNavigator;
    var curPage = parseInt(currentPage);
//logit ('loadPage_pagination: '+  divId +','+ t.cpPager.divId +','+ currentPage +','+ callbackFunction +','+ totalPages +','+ t.cpPager.getCurrentPage());
    if (divId == t.cpPager.divId) // if 'old' style ...  
      unsafeWindow[callbackFunction] (t.cpPager.getCurrentPage());
    else
      unsafeWindow[callbackFunction] (currentPage);
  },
    
  ctrlPagination : function (navDivId, numPages, notify, curPage){
    var t = PageNavigator;
//logit ('ctrlPagination (divid:'+ navDivId +')');    
    if (document.getElementById(navDivId).firstChild == null)
      document.getElementById(navDivId).appendChild (t.cpPager.getHtmlElement());   
    t.cpPager.setPageCount(numPages);
    t.cpPager.divId = navDivId;
    if (!curPage)
      curPage = 1;
    t.cpPager.gotoPage(curPage);
    t.cpPager.onClick = unsafeWindow[notify];
    unsafeWindow.pageNavigatorView = t.cpPager;
  },  
  
  enable : function (tf){
    var t = PageNavigator;
    t.modalMessagesFunc.setEnable(tf);
    if (tf){
      unsafeWindow.ctrlPagination = t.ctrlPagination;
      unsafeWindow.loadPage_pagination = t.loadPage_pagination;
    } else {
      unsafeWindow.ctrlPagination = t.ctrlPaginationOld;
      unsafeWindow.loadPage_pagination = t.loadPage_paginationOld;
    }
  },
  
  isAvailable : function (){
    var t = PageNavigator;
    return t.modalMessagesFunc.isAvailable();
  },
  
  Cpager : function (a, b){
    // public function protos ...
    this.getHtmlElement = getHtmlElement;    
    this.setPageCount = setPageCount;    
    this.getPageCount = getPageCount;    
    this.getCurrentPage = getCurrentPage;    
    this.gotoPage = gotoPage;    
    this.e_but = e_but;    
    this.e_inp = e_inp;
    //    
    var t = this;
    this.onClick = null;
    this.numPages = b;
    this.curPage = a;
    this.oldStyle = false;
    
    function getHtmlElement (){
      function aButton (msg, evtPage){
        return '<A class=ptPageNav onclick="pageNavigatorView.e_but(\''+ evtPage +'\')"><SPAN class=ptPageNav>'+ msg +'</span></a>';
      }
      var div = document.createElement ('div');
      div.id = 'ptPageNavBar';
      div.innerHTML = '<STYLE>table.ptPageNav tr td  {border:none; text-align:center; padding:0px 1px;}\
        span.ptPageNav {font-size:12px; background:inherit; line-height:135%}\
        A.ptPageNav {background-color:#44e; color:#ff4; display:block; border:1px solid #666666; height:18px; width:18px;}\
        A.ptPageNav:hover {background-color:#66f;}\
        A.ptPageNav:active {background-color:#186}\
        </style>\
        <TABLE class=ptPageNav><TR valign=middle>\
        <TD style="margin-right:15px">'+ aButton('<SPAN style="padding-right:0.8em; letter-spacing:-0.99em;">&#x258f;&#x258f;&#x25c4;</span>', 'F') +'</td>\
        <TD>'+ aButton('&#x25c4', '-') +'</td>\
        <TD>'+ aButton('&#x25ba', '+') +'</td>\
        <TD style="margin-right:15px">'+ aButton('<SPAN style="padding-right:1.05em; letter-spacing:-0.99em;">&#x25ba;&#x2595;&#x2595;</span>', 'L') +'</td>\
        <TD width=20></td><TD>Seite <INPUT id=ptPagerPageNum onChange="pageNavigatorView.e_inp()" type=text size=1> von <span id=ptPagerNumPages>?</span></td>\
        </tr></table>';
      var mml = document.getElementById('modal_msg_list');
      if (mml != null)
        mml.style.minHeight = '320px';
      return div;
    }

    function getPageCount(){    // koc needs for 'back'
      return t.numPages;
    }    
    function getCurrentPage(){    // koc needs for 'back'
      return t.curPage;
    }    
    function setPageCount(c){
      t.numPages = c;
      document.getElementById('ptPagerNumPages').innerHTML = c;
      var mml = document.getElementById('modal_msg_list');
      if (mml != null){
        if (document.getElementById('modal_msg_tabs_report').className.indexOf('selected') >= 0)
          mml.style.minHeight = '460px';
        else
          mml.style.minHeight = '320px';
      }
    }
    function gotoPage(p){
      t.curPage = parseIntZero(p);
      document.getElementById('ptPagerPageNum').value = t.curPage;
    }
    function e_but (p){
      if (p=='F' && t.curPage!=1)
        loadPage(1);
      else if (p=='-' && t.curPage>1)
        loadPage(t.curPage-1);
      else if (p=='+' && t.curPage<t.numPages)
        loadPage(t.curPage+1);
      else if (p=='L' && t.curPage!=t.numPages)
        loadPage(t.numPages);
      function loadPage (p){
        if (t.oldStyle)
      t.gotoPage(p);
        t.onClick (p);
      }
    }
    function e_inp (p){
      var pageNum = parseIntZero(document.getElementById('ptPagerPageNum').value);
      t.onClick(pageNum);
    }
  },
}


function addScript (scriptText){
  var scr = document.createElement('script');   
  scr.innerHTML = scriptText;
  document.body.appendChild(scr);
//    setTimeout ( function (){document.body.removeChild(scr);}, 500);
}
addScript ('uwuwuwFunc = function (text){ eval (text);  }');  



// TODO: Handle multiple instances altering same function!!   ****************************
var CalterUwFunc = function (funcName, findReplace) {
  var t = this;
  this.isEnabled = false;
  this.isAvailable = isAvailable;
  this.setEnable = setEnable;
  this.funcOld = null;  
  this.funcNew = null;
  try {
    var x = funcName.split('.');
    var f = unsafeWindow;
    for (var i=0; i<x.length; i++)
      f = f[x[i]];
    ft = f.toString();
    this.funcOld = f;
    var rt = ft.replace ('function '+ funcName, 'function');
    for (var i=0; i<findReplace.length; i++){
      x = rt.replace(findReplace[i][0], findReplace[i][1]);
      if (x == rt)  // if not found
        return;
      rt = x;
    }
    this.funcNew = rt;
  } catch (err) {
  }
      
  function setEnable (tf){
    if (t.funcNew == null)
      return;
    if (t.isEnabled != tf){
      if (tf){
//        var scr = document.createElement('script');   
//        scr.innerHTML = funcName +' = '+ t.funcNew;
//        document.body.appendChild(scr);
//        setTimeout ( function (){document.body.removeChild(scr);}, 500);
unsafeWindow.uwuwuwFunc(funcName +' = '+ t.funcNew);
        t.isEnabled = true;
      } else {
      var x = funcName.split('.');
      var f = unsafeWindow;
      for (var i=0; i<x.length-1; i++)
        f = f[x[i]];
      f[x[x.length-1]] = this.funcOld;
        t.isEnabled = false;
      }
    }
  }
  function isAvailable (){
    if (t.funcNew == null)
      return false;
    return true;
  }
};


var MessageCounts = {
  messagesNotifyFunc : null,
  
  init : function (){
    var t = MessageCounts;
    t.messagesNotifyFunc = new CalterUwFunc ('messages_notify_bug', [
        ['$("chrome_messages_notify").innerHTML = a;', 'msgCount_hook(a);'],
        ['$("chrome_messages_notify").removeClassName("noCount");', ''],
        ['$("chrome_messages_notify").addClassName("noCount");','msgCount_hook(a);']
    ]);
    if (t.messagesNotifyFunc.isAvailable()){
      unsafeWindow.msgCount_hook = t.msgCount_hook;
      e = document.getElementById('chrome_messages_notify');
      span = document.createElement('span');
span.id = 'chrome_messages_notify_Msg';
      e.parentNode.insertBefore (span, e);
    span.style.visibility = 'hidden';
      if (Options.fixMsgCount){
        t.enable (true);
        setTimeout (unsafeWindow.messages_notify_bug, 1000);
      }
    }
  },
  
  msgCount_hook : function (a){
var l = document.getElementById('chrome_messages_notify_Msg');
    var r = document.getElementById('chrome_messages_notify');
var newMessages = parseInt(Seed.newMailCount);
var newReports = parseInt(Seed.newTradeReports) + parseInt(Seed.newReportCount);
//logit('Messages: '+ newMessages + ',' + ' Reports: '+ newReports);
l.innerHTML = newMessages;
 r.innerHTML = newReports;
 l.className = 'notificationCount';
 r.className = 'notificationCount';
 l.style.margin = '10px 0 0 10px';
 r.style.margin = '-23px 0 0 40px';
 l.style.visibility = (newMessages > 0) ? 'visible' : 'hidden' ;
r.style.visibility = (newReports > 0) ? 'visible' : 'hidden' ;
  },

  enable : function (tf){
    var t = MessageCounts;
    t.messagesNotifyFunc.setEnable (tf);
    if (!tf)
      document.getElementById('chrome_messages_notifyL').style.display = 'none';
    setTimeout (unsafeWindow.messages_notify_bug, 0);
  },
    
  isAvailable : function (){
    var t = MessageCounts;
    return t.messagesNotifyFunc.isAvailable();
  },
}


var WarnZeroAttack = {
  modalAttackFunc : null,  
  
  init : function (){
    var t = WarnZeroAttack;
    t.modalAttackFunc = new CalterUwFunc ('modal_attack', [['modal_attack_check()', 'modalAttack_hook()']]);
    unsafeWindow.modalAttack_hook = t.hook;
    t.modalAttackFunc.setEnable(Options.fixWarnZero);
  },
   
  setEnable : function (tf){
    var t = WarnZeroAttack;
    t.modalAttackFunc.setEnable (tf);
  },
  
  isAvailable : function (){
    var t = WarnZeroAttack;
    return t.modalAttackFunc.isAvailable();
  },
    
  hook : function (){
    var t = WarnZeroAttack;
    if (parseIntZero(document.getElementById('modal_attack_target_coords_x').value) == 0
    && parseIntZero(document.getElementById('modal_attack_target_coords_y').value) == 0){
      new CdialogCancelContinue ('<SPAN class=boldRed>Du rennst grade auf 0,0!</span>', null, unsafeWindow.modal_attack_check, document.getElementById('modalInner1'));      
    } else {
      unsafeWindow.modal_attack_check();
    }
  },
  
}

function distance (d, f, c, e) {
  var a = 750;
  var g = a / 2;
  var b = Math.abs(c - d);
  if (b > g)
    b = a - b;
  var h = Math.abs(e - f);
  if (h > g)
    h = a - h;
  return Math.round(100 * Math.sqrt(b * b + h * h)) / 100;
};

var MapDistanceFix = {
  popSlotsFunc : null,
  init : function (){
    var t = MapDistanceFix;
    t.popSlotsFunc = new CalterUwFunc ('MapObject.prototype.populateSlots', [['this.distance', 'fixMapDistance_hook']]);
    if (t.popSlotsFunc.isAvailable()){
      unsafeWindow.fixMapDistance_hook = t.fixMapDistance_hook;
      if (Options.fixMapDistance)
        t.enable (true);

    }
  },
  fixMapDistance_hook : function (cityX, cityY, tileX, tileY){
    var city = Cities.byID[unsafeWindow.currentcityid];
    return distance (city.x, city.y, tileX, tileY);
  },
  enable : function (tf){
    var t = MapDistanceFix;
    t.popSlotsFunc.setEnable (tf);
  },
  isAvailable : function (){
    var t = MapDistanceFix;
    return t.popSlotsFunc.isAvailable();
  },
}


var tabManager = {
  tabList : {},           // {name, obj, div}
  currentTab : null,
  
  init : function (mainDiv){
    var t = tabManager;
    var sorter = [];
    for (k in Tabs){
      if (!Tabs[k].tabDisabled){  
        t.tabList[k] = {};
        t.tabList[k].name = k;
        t.tabList[k].obj = Tabs[k];
        if (Tabs[k].tabLabel != null)
          t.tabList[k].label = Tabs[k].tabLabel;
        else
          t.tabList[k].label = k;
        if (Tabs[k].tabOrder != null)
          sorter.push([Tabs[k].tabOrder, t.tabList[k]]);
        else
          sorter.push([1000, t.tabList[k]]);
        t.tabList[k].div = document.createElement('div');
      }
    }

    sorter.sort (function (a,b){return a[0]-b[0]});
    var m = '<TABLE cellspacing=0 class=ptMainTab><TR>';
    for (var i=0; i<sorter.length; i++)
      m += '<TD class=spacer></td><TD class=notSel id=pttc'+ sorter[i][1].name +' ><A><SPAN>'+ sorter[i][1].label +'</span></a></td>';
    m += '<TD class=spacer width=90% align=right>&nbsp;</td></tr></table>';
    mainPop.getTopDiv().innerHTML = m;
    
    t.currentTab = null;
    for (k in t.tabList) {
      if (t.tabList[k].name == Options.currentTab)
        t.currentTab = t.tabList[k] ;
      document.getElementById('pttc'+ k).addEventListener('click', this.e_clickedTab, false);
      var div = t.tabList[k].div;
      div.style.display = 'none';
      div.style.height = '100%';
      div.style.maxWidth = '737px';
      div.style.overflowX = 'auto';
      mainDiv.appendChild(div);
      try {
        t.tabList[k].obj.init(div);
      } catch (e){
        div.innerHTML = "INIT ERROR: "+ e;
      }
    }
    if (t.currentTab == null)
      t.currentTab = sorter[0][1];    
    t.setTabStyle (document.getElementById ('pttc'+ t.currentTab.name), true);
    t.currentTab.div.style.display = 'block';
  },
  
  hideTab : function (){
    var t = tabManager;
    t.currentTab.obj.hide();
  },
  
  showTab : function (){
    var t = tabManager;
    t.currentTab.obj.show();
  },
    
  setTabStyle : function (e, selected){
    if (selected){
      e.className = 'sel';
    } else {
      e.className = 'notSel';
    }
  },
  
  e_clickedTab : function (e){
    var t = tabManager;

    newTab = t.tabList[e.target.parentNode.parentNode.id.substring(4)];
    if (t.currentTab.name != newTab.name){
      t.setTabStyle (document.getElementById ('pttc'+ t.currentTab.name), false);
      t.setTabStyle (document.getElementById ('pttc'+ newTab.name), true);
      t.currentTab.obj.hide ();
      t.currentTab.div.style.display = 'none';
      t.currentTab = newTab;
      newTab.div.style.display = 'block';
      Options.currentTab = newTab.name;      
    }
    newTab.obj.show();
  },
}


function setTabStyle (e, selected){
  if (selected){
    e.className = 'matTabSel';
  } else {
    e.className = 'matTabNotSel';
  }
}

function clickedTab (e){
  who = e.target.id.substring(2);
  newObj = my[who];
  currentObj = my[currentName];
  if (currentName != who){
    setTabStyle (document.getElementById ('aa'+currentName), false);
    setTabStyle (document.getElementById ('aa'+who), true);
    if (currentObj){
      currentObj.hide ();
      currentObj.getContent().style.display = 'none';
    }
    currentName = who;
    cont = newObj.getContent();
    newObj.getContent().style.display = 'block';
  }
  newObj.show();
}

function mouseMainTab (me){
  if (me.button == 2){
    var c = getClientCoords (document.getElementById('main_engagement_tabs'));
    mainPop.setLocation ({x: c.x+4, y: c.y+c.height});
  }
}

function eventHideShow (){
  if (mainPop.toggleHide(mainPop)){
    tabManager.showTab();
    Options.ptWinIsOpen = true;
  } else {
    tabManager.hideTab();
    Options.ptWinIsOpen = false;
  }
  saveOptions();
}

function hideMe (){
  if (!Options.ptWinIsOpen)
    return;
  mainPop.show (false);
  tabManager.showTab();
  Options.ptWinIsOpen = false;
  saveOptions();
}
function showMe (){
  mainPop.show (true);
  tabManager.showTab();
  Options.ptWinIsOpen = true;
  saveOptions();
}


function addMyFunction (func){      // add function to run in our own scope
  unsafeWindow[func.name] = func;
}

function addUwFunction (func){      // add function to run in unsafeWindow's scope
  scr = document.createElement('script');
  scr.innerHTML = func.toString();
  document.body.appendChild(scr);
}

function alterUwFunction (funcName, frArray){
  try {
    funcText = unsafeWindow[funcName].toString();
    rt = funcText.replace ('function '+funcName, 'function');
    for (i=0; i<frArray.length; i++){
      x = rt.replace(frArray[i][0], frArray[i][1]);
      if (x == rt)
        return false;
      rt = x;
    }
    js = funcName +' = '+ rt;
    var scr=document.createElement('script');
    scr.innerHTML=js;
    document.body.appendChild(scr);
    return true;
  } catch (err) {
    return false;
  }
}

function setCities(){
  Cities.numCities = Seed.cities.length;
  Cities.cities = [];
  Cities.byID = {};
  for (i=0; i<Cities.numCities; i++){
    city = {};
    city.idx = i;
    city.id = parseInt(Seed.cities[i][0]);
    city.name = Seed.cities[i][1];
    city.x = parseInt(Seed.cities[i][2]);
    city.y = parseInt(Seed.cities[i][3]);
    city.tileId = parseInt(Seed.cities[i][5]);
    city.provId = parseInt(Seed.cities[i][4]);
    Cities.cities[i] = city;
    Cities.byID[Seed.cities[i][0]] = city;
  }
}

function officerId2String (oid){
  if (oid==null)
    return '';
  else if (oid==3)
    return 'Offizier';
  else if (oid==2)
    return 'Vize Kanzler';
  else if (oid==1)
    return 'Kanzler';
  return '';
}


// onClick (city{name, id, x, y}, x, y)   city may be null!
function CdispCityPicker (id, span, dispName, notify, selbut){
  function CcityButHandler (t){
    var that = t;
    this.clickedCityBut = clickedCityBut;
    function clickedCityBut (e){
      if (that.selected != null)
        that.selected.className = "ptcastleBut ptcastleButNon";
      that.city = Cities.cities[e.target.id.substr(that.prefixLen)];
      if (that.dispName)
        document.getElementById(that.id+'cname').innerHTML = that.city.name;
      e.target.className = "ptcastleBut ptcastleButSel";
      that.selected = e.target;
      if (that.coordBoxX){
        that.coordBoxX.value = that.city.x;
        that.coordBoxY.value = that.city.y;
        that.coordBoxX.style.backgroundColor = '#ffffff';
        that.coordBoxY.style.backgroundColor = '#ffffff';
      }
      if (that.notify != null)
        that.notify(that.city, that.city.x, that.city.y);
    }
  }

  function selectBut (idx){
    document.getElementById(this.id+'_'+idx).click();
  }

  function bindToXYboxes (eX, eY){
    function CboxHandler (t){
      var that = t;
      this.eventChange = eventChange;
      if (that.city){
        eX.value = that.city.x;
        eY.value = that.city.y;
      }
      function eventChange (){
        var x = parseInt(that.coordBoxX.value, 10);
        var y = parseInt(that.coordBoxY.value, 10);
        if (isNaN(x) || x<0 || x>750){
          that.coordBoxX.style.backgroundColor = '#ff8888';
          return;
        }
        if (isNaN(y) || y<0 || y>750){
          that.coordBoxY.style.backgroundColor = '#ff8888';
          return;
        }
        that.coordBoxX.style.backgroundColor = '#ffffff';
        that.coordBoxY.style.backgroundColor = '#ffffff';
        if (that.notify != null)
          that.notify (null, x, y);
      }
    }
    this.coordBoxX = eX;
    this.coordBoxY = eY;
    var bh = new CboxHandler(this);
    eX.size=2;
    eX.maxLength=3;
    eY.size=2;
    eY.maxLength=3;
    eX.addEventListener('change', bh.eventChange, false);
    eY.addEventListener('change', bh.eventChange, false);
  }

  this.selectBut = selectBut;
  this.bindToXYboxes = bindToXYboxes;
  this.coordBoxX = null;
  this.coordBoxY = null;
  this.id = id;
  this.dispName = dispName;
  this.prefixLen = id.length+1;
  this.notify = notify;
  this.selected = null;
  this.city = null;
  var m = '';
  for (var i=0; i<Cities.cities.length; i++)
    m += '<INPUT class="ptcastleBut ptcastleButNon" id="'+ id +'_'+ i +'" value="'+ (i+1) +'" type=submit \>';
  if (dispName)
    m += ' &nbsp; <br><b>Stadt Name:</b> &nbsp; <SPAN style="display:inline-block; width:85px; font-weight:bold;" id='+ id +'cname' +'></span>';
  span.innerHTML = m;
  var handler = new CcityButHandler(this);
  for (var i=0; i<Cities.cities.length; i++)
    document.getElementById (id+'_'+i).addEventListener('click', handler.clickedCityBut, false);
  if (selbut != null)
    this.selectBut(selbut);
};


function CdialogCancelContinue (msg, canNotify, contNotify, centerElement){
  var pop = new CPopup ('ptcancont', 0, 0, 400,200, true, canNotify);
  if (centerElement)
    pop.centerMe(centerElement);
  else
    pop.centerMe(document.body);
  pop.getTopDiv().innerHTML = '<CENTER>KoC Power Tools</center>';
  pop.getMainDiv().innerHTML = '<TABLE class=ptTab align=center style="height: 100%"><TR align=center height=90%><TD>'+ msg +'</td></tr>\
      <TR align=center><TD><INPUT id=ptcccancel type=submit value="CANCEL" \> &nbsp; &nbsp; <INPUT id=ptcccontin type=submit value="CONTINUE" \></td></tr></table>';
  document.getElementById('ptcccancel').addEventListener ('click', function (){pop.show(false); if (canNotify) canNotify();}, false);
  document.getElementById('ptcccontin').addEventListener ('click', function (){pop.show(false); if (contNotify) contNotify();}, false);
  pop.show(true);
}


// TODO: make class (multiple instances needed)
function dialogRetry (errMsg, seconds, onRetry, onCancel){
  seconds = parseInt(seconds);
  var pop = new CPopup ('ptretry', 0, 0, 400,200, true);
  pop.centerMe(mainPop.getMainDiv());
  pop.getTopDiv().innerHTML = '<CENTER>KoC Power Tools - Deutsch</center>';
  pop.getMainDiv().innerHTML = '<CENTER><BR><FONT COLOR=#550000><B>Fehlermeldung:</b></font><BR><BR><DIV id=paretryErrMsg></div>\
      <BR><BR><B>Auto Refresh in <SPAN id=paretrySeconds></b></span> Sekunden...<BR><BR><INPUT id=paretryCancel type=submit value="Abbruch Wiederholen" \>';
  document.getElementById('paretryCancel').addEventListener ('click', doCancel, false);
  pop.show(true);
  
  document.getElementById('paretryErrMsg').innerHTML = errMsg;
  document.getElementById('paretrySeconds').innerHTML = seconds;
  var rTimer = setTimeout (doRetry, seconds*1000);
  countdown ();

  function countdown (){
    document.getElementById('paretrySeconds').innerHTML = seconds--;
    if (seconds > 0)
      cdTimer = setTimeout (countdown, 1000);
  }
  function doCancel(){
    clearTimeout (rTimer);
    clearTimeout (cdTimer);
    pop.destroy();
    onCancel ();
  }
  function doRetry (){
    clearTimeout (rTimer);
    clearTimeout (cdTimer);
    pop.show(false);
    onRetry();
  }
}



function implodeUrlArgs (obj){
  var a = [];
  for (var k in obj)
    a.push (k +'='+ encodeURI(obj[k]) );
  return a.join ('&');    
}

// NOTE: args can be either a string which will be appended as is to url or an object of name->values
function addUrlArgs (url, args){
  if (!args)
    return url;
  if (url.indexOf('?') < 0)
    url += '?';
  else if (url.substr(url.length-1) != '&')
    url += '&';    
  if (matTypeof(args == 'object'))
    return url + implodeUrlArgs (args);    
  return url + args;
}

// emulate protoype's Ajax.Request ...
function AjaxRequest (url, opts){
  var headers = {
    'X-Requested-With': 'XMLHttpRequest',
    'X-Prototype-Version': '1.6.1',
    'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
  };
  var ajax = null;

if (DEBUG_TRACE_AJAX) logit ("AJAX: "+ url +"\n" + inspect (opts, 3, 1));  
    
  if (window.XMLHttpRequest)
    ajax=new XMLHttpRequest();
  else
    ajax=new ActiveXObject("Microsoft.XMLHTTP");
  
  if (opts.method==null || opts.method=='')
    method = 'GET';
  else
    method = opts.method.toUpperCase();  
    
  if (method == 'POST'){
    headers['Content-type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
  } else if (method == 'GET'){
    addUrlArgs (url, opts.parameters);
  }

  ajax.onreadystatechange = function(){
//  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; states 0-4
    if (ajax.readyState==4) {
      if (ajax.status >= 200 && ajax.status < 305)
        if (opts.onSuccess) opts.onSuccess(ajax);
      else
        if (opts.onFailure) opts.onFailure(ajax);
    } else {
      if (opts.onChange) opts.onChange (ajax);
    }
  }  
    
  ajax.open(method, url, true);   // always async!

  for (var k in headers)
    ajax.setRequestHeader (k, headers[k]);
  if (matTypeof(opts.requestHeaders)=='object')
    for (var k in opts.requestHeaders)
      ajax.setRequestHeader (k, opts.requestHeaders[k]);
      
  if (method == 'POST'){
    var a = [];
    for (k in opts.parameters)
      a.push (k +'='+ opts.parameters[k] );
    ajax.send (a.join ('&'));
  } else               {
    ajax.send();
  }
}   



function MyAjaxRequest (url, o, noRetry){
if (DEBUG_TRACE) logit (" 0 myAjaxRequest: "+ url +"\n" + inspect (o, 2, 1));
  var opts = unsafeWindow.Object.clone(o);
  var wasSuccess = o.onSuccess;
  var wasFailure = o.onFailure;
  var retry = 0;
  var delay = 5;
  var noRetry = noRetry===true?true:false;
  opts.onSuccess = mySuccess;
  opts.onFailure = myFailure;

if (DEBUG_TRACE) logit (" 1a myAjaxRequest: "+ url +"\n" + inspect (o, 2, 1));
  new AjaxRequest(url, opts);
  return;

  function myRetry(){
    ++retry;
    new AjaxRequest(url, opts);
    delay = delay * 1.25;
  }

  function myFailure(){
    var o = {};
if (DEBUG_TRACE) logit ("myAjaxRequest.myFailure(): "+ inspect(rslt, 1, 1));
    o.ok = false;
    o.errorMsg = "AJAX Communication Failure";
    wasFailure (o);
  }

  function mySuccess (msg){
    var rslt = eval("(" + msg.responseText + ")");
    var x;
    if (rslt.ok){
if (DEBUG_TRACE) logit (" 1b myAjaxRequest.mySuccess(): "+ inspect(rslt, 1, 1));
      rslt.errorMsg = null;   ///// !!!!!!!!!!!!!  ************
      if (rslt.updateSeed)
        unsafeWindow.update_seed(rslt.updateSeed);
      wasSuccess (rslt);
      return;
    }
if (DEBUG_TRACE) logit (" 1b myAjaxRequest.mySuccess() !ok : "+ inspect(rslt, 3, 1));
    rslt.errorMsg = unsafeWindow.printLocalError((rslt.error_code || null), (rslt.msg || null), (rslt.feedback || null));
    if ( (x = rslt.errorMsg.indexOf ('<br><br>')) > 0)
      rslt.errorMsg = rslt.errorMsg.substr (0, x-1);
    if (!noRetry && (rslt.error_code==0 ||rslt.error_code==8 || rslt.error_code==1 || rslt.error_code==3)){
      dialogRetry (rslt.errorMsg, delay, function(){myRetry()}, function(){wasSuccess (rslt)});
    } else {
      wasSuccess (rslt);
    }
  }
}





// returns: 'neutral', 'friendly', or 'hostile'
function getDiplomacy (aid) {
  if (Seed.allianceDiplomacies == null)
    return 'Neutral';
  if (Seed.allianceDiplomacies.friendly && Seed.allianceDiplomacies.friendly['a'+aid] != null)
    return 'Freundlich';
  if (Seed.allianceDiplomacies.hostile && Seed.allianceDiplomacies.hostile['a'+aid] != null)
    return 'Feindlich';
  return 'Neutral';
};
// returns: 'neutral', 'friendly', ally, or 'hostile'
function getDiplomacy2 (aid) {
  if (Seed.allianceDiplomacies == null)
    return 'Neutral';
  if (Seed.allianceDiplomacies.friendly && Seed.allianceDiplomacies.friendly['a'+aid] != null)
    return 'Freundlich';
  if (Seed.allianceDiplomacies.hostile && Seed.allianceDiplomacies.hostile['a'+aid] != null)
    return 'Feindlich';
  if (aid == Seed.allianceDiplomacies.allianceId)
    return 'Alliierte';
  return 'Neutral';
};

function getMyAlliance (){
  if (Seed.allianceDiplomacies==null || Seed.allianceDiplomacies.allianceName==null)
    return [0, 'None'];
  else
    return [Seed.allianceDiplomacies.allianceId, Seed.allianceDiplomacies.allianceName];
}



// TODO: Check times for expired marches !?!?!
// note: unselected city has outdated info

function getMarchInfo (){
  var ret = {};

  ret.marchUnits = [];
  ret.returnUnits = [];
  ret.resources = [];
  for (i=0; i<13; i++){
    ret.marchUnits[i] = 0;
    ret.returnUnits[i] = 0;
  }
  for (i=0; i<5; i++){
    ret.resources[i] = 0;
  }

  var now = unixTime();

  for(i=0; i<Cities.numCities; i++) {   // each city
    cityID = 'city'+ Cities.cities[i].id;
    for (k in Seed.queue_atkp[cityID]){   // each march
      march = Seed.queue_atkp[cityID][k];
      if (typeof (march) == 'object'){
        for (ii=0; ii<13; ii++){
          ret.marchUnits[ii] += parseInt (march['unit'+ ii +'Count']);
          ret.returnUnits[ii] += parseInt (march['unit'+ ii +'Return']);
        }
        for (ii=1; ii<5; ii++){
          ret.resources[ii] += parseInt (march['resource'+ ii]);
        }
          ret.resources[0] += parseInt (march['gold']);
      }
// TODO: fixup completed marches
// TODO: Assume transport is complete ?
    }
  }
  return ret;
}

var fortNamesShort = {
  53: "Crossbows",
  55: "Trebuchet",
  60: "Trap",
  61: "Caltrops",
  62: "Spiked Barrier",
}

// returns {count, maxlevel}
function getCityBuilding (cityId, buildingId){
  var b = Seed.buildings['city'+cityId];
  var ret = {count:0, maxLevel:0};
  for (var i=1; i<33; i++){
    if (b['pos'+i] && b['pos'+i][0] == buildingId){
      ++ret.count;
      if (parseInt(b['pos'+i][1]) > ret.maxLevel)
        ret.maxLevel = parseInt(b['pos'+i][1]);
    }
  }
  return ret;
}

// example: http://www150.kingdomsofcamelot.com
function GetServerId() {
  var m=/^[a-zA-Z]+([0-9]+)\./.exec(document.location.hostname);
  if(m)
    return m[1];
  return '';
}

function logit (msg){
  var serverID = GetServerId();
  var now = new Date();
  GM_log (serverID +' @ '+ now.toTimeString().substring (0,8) +'.' + now.getMilliseconds() +': '+  msg);
}



/************ DEBUG WIN *************/
var debugWin = {
  popDebug : null,
  dbDefaultNot : 'tech,tutorial,items,quests,wilderness,wildDef,buildings,knights,allianceDiplomacies,appFriends,players',
  dbSelect : {},

  doit : function (){
    var t = debugWin;    

    function syncBoxes (){
      var div = document.getElementById('dbpoplist');
      for (var i=0; i<div.childNodes.length; i++){
        if (div.childNodes[i].type && div.childNodes[i].type=='checkbox'){
          var name=div.childNodes[i].name.substr(6);
          div.childNodes[i].checked = t.dbSelect[name];
        }
      }
    }
    function clickedAll (){
      for (var k in t.dbSelect)
        t.dbSelect[k] = true;
      syncBoxes();
    }
    function clickedNone (){
      for (var k in t.dbSelect)
        t.dbSelect[k] = false;
      syncBoxes();
    }
    function clickedDefaults (){
      for (k in t.dbSelect)
        t.dbSelect[k] = true;
      var not = t.dbDefaultNot.split(',');
      for (var i=0; i<not.length; i++)
        t.dbSelect[not[i]] = false;
      syncBoxes();
    }
    function clickedShow (){
      var now = new Date();
      var myseed = unsafeWindow.Object.clone (Seed);
      var div = document.getElementById('dbpoplist');
      for (var i=0; i<div.childNodes.length; i++){
        if (div.childNodes[i].type && div.childNodes[i].type=='checkbox'){
          var name=div.childNodes[i].name.substr(6);
          if (!div.childNodes[i].checked)
            delete myseed[name];
        }
      }
      WinLog.write ("seed @ "+ unixTime()  +" ("+ now +")\n\n"+ inspect (myseed, 8, 1));
      myseed=null;
    }
    
    function clickedShowScripts (){
      var scripts = document.getElementsByTagName('script');
      for (var i=0; i<scripts.length; i++){
        if (scripts[i].src!=null && scripts[i].src!='')
          WinLog.write ('<A TARGET=_tab HREF="'+ scripts[i].src +'">'+ scripts[i].src +'</a>');
      }
    }
    
    if (t.popDebug == null){  
      t.popDebug = new CPopup ('db', 0, 0, 400,500, true);
      t.popDebug.getTopDiv().innerHTML = 'DEBUG';
      t.popDebug.getMainDiv().innerHTML = '<DIV><INPUT type=submit id=dbsuball value=ALL> &nbsp; <INPUT type=submit id=dbsubnone value=NONE> &nbsp; \
        <INPUT type=submit id=dbdefaults value=DEFAULTS> &nbsp; <INPUT type=submit id=dbsubdo value=SHOW> &nbsp; <INPUT type=submit id=dbsubscripts value=SCRIPTS></div>\
        <DIV id=dbpoplist style="max-height:400px; height:400px; overflow-y:auto"></div>';
      var div = document.getElementById('dbpoplist');
      for (var k in Seed)
        t.dbSelect[k] = true;
      var not = t.dbDefaultNot.split(',');
      for (var i=0; i<not.length; i++)
        t.dbSelect[not[i]] = false;
      var m = [];
      for (k in t.dbSelect){
        m.push ('<INPUT type=checkbox ');
        m.push ('name="dbpop_');
        m.push (k);
        m.push ('"> &nbsp; ');
        m.push (k);
        m.push ('<BR>');
      }
      div.innerHTML = m.join ('');
      document.getElementById('dbsuball').addEventListener('click', clickedAll, false);
      document.getElementById('dbsubnone').addEventListener('click', clickedNone, false);
      document.getElementById('dbdefaults').addEventListener('click', clickedDefaults, false);
      document.getElementById('dbsubdo').addEventListener('click', clickedShow, false);
      document.getElementById('dbsubscripts').addEventListener('click', clickedShowScripts, false);
      syncBoxes();
    }
    t.popDebug.show (true);
  },
}


function saveOptions (){
  var serverID = GetServerId();
  GM_setValue ('Options_'+serverID, JSON2.stringify(Options));
}

function readOptions (){
  var serverID = GetServerId();
  s = GM_getValue ('Options_'+serverID);
  if (s != null){
    opts = JSON2.parse (s);
    for (k in opts)
      Options[k] = opts[k];
  }
}


/***
***/
var myServers = {   // incomplete, untested
  serverlist : null,
  
  get : function (notify){
    if (myServers.serverlist){
      notify (myServers.serverlist);
      return;
    }
    var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/myServers.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function(rslt) {
logit (inspect (rslt, 3, 1));  
        if (notify)      
          notify (myServers.serverlist);
      },
      onFailure: function(rslt) {
      }
    });
  },
};


function createButton (label){
  var a=document.createElement('a');
  a.className='button20';
  a.innerHTML='<span style="color: #ff6">'+ label +'</span>';
  return a;
}

function AddMainTabLink(text, eventListener, mouseListener) {
  var a = createButton (text);
  a.className='tab';
  var tabs=document.getElementById('main_engagement_tabs');
  if(!tabs) {
    tabs=document.getElementById('topnav_msg');
    if (tabs)
      tabs=tabs.parentNode;
  }
  if (tabs) {
    var e = tabs.parentNode;
    var gmTabs = null;
    for (var i=0; i<e.childNodes.length; i++){
      var ee = e.childNodes[i];
//if (ee.tagName=='DIV') logit ("CHILD: "+  ee.tagName +' : '+ ee.className+' : '+ ee.id);      
      if (ee.tagName && ee.tagName=='DIV' && ee.className=='tabs_engagement' &&  ee.id!='main_engagement_tabs'){
        gmTabs = ee;
        break;
      }
    }
    if (gmTabs == null){
      gmTabs = document.createElement('div');
      gmTabs.className='tabs_engagement';
      gmTabs.style.background='none';
      tabs.parentNode.insertBefore (gmTabs, tabs);
      gmTabs.style.whiteSpace='nowrap';
      gmTabs.style.width='735px';
      gmTabs.lang = 'en_PT';
    }
    if (gmTabs.firstChild)
      gmTabs.insertBefore (a, gmTabs.firstChild);
    else
      gmTabs.appendChild(a);
    a.addEventListener('click',eventListener, false);
    if (mouseListener != null)
      a.addEventListener('mousedown',mouseListener, true);
    return a;
  }
  return null;
}

function coordLink (x, y){
  var m = [];
  m.push ('(<a onclick="ptGotoMapHide (');
  m.push (x);
  m.push (',');
  m.push (y);
  m.push ('); return false">');
  m.push (x);
  m.push (',');
  m.push (y);
  m.push ('</a>)');  
  return m.join('');
}


unsafeWindow.ptGotoMapHide = function (x, y){
  try {
    unsafeWindow.Modal.hideModal();
  } catch (e){ }
  try {
    Modal.hideModal();
  } catch (e){ }
  unsafeWindow.ptGotoMap (x, y);  
}



unsafeWindow.ptGotoMap = function (x, y){
  if (Options.hideOnGoto)
    hideMe ();
  setTimeout (function (){
    document.getElementById('mapXCoor').value = x;
    document.getElementById('mapYCoor').value = y;
    unsafeWindow.reCenterMapWithCoor();
    var a = document.getElementById("mod_views").getElementsByTagName("a");
    for (var b = 0; b < a.length; b++) {
        a[b].className = ""
    }
    document.getElementById('mod_views_map').className = "sel";
    document.getElementById("maparea_city").style.display = 'none';
    document.getElementById("maparea_fields").style.display = 'none';
    document.getElementById("maparea_map").style.display = 'block';
    unsafeWindow.tutorialClear()
  }, 0);
};


/**********************************************************************************/

function makeButton20 (label){
  var a = document.createElement('a');
  a.className = "button20 ptButton20";
  var s = document.createElement('span');
  s.innerHTML = label;
  a.appendChild (s);
  return a;
}

function strButton20 (label, tags){
  if (tags == null)
    tags = '';
  return ('<TABLE class=ptNoPad><TR><TD><A class="button20 ptButton20" '+ tags +'><SPAN>'+ label +'</span></a></td></tr></table>' );
}

function strButton14 (label, tags){
  if (tags == null)
    tags = '';
  return ('<A class="button14 ptButton20" '+ tags +'><SPAN>'+ label +'</span></a>' );
}

function cityStatusString (cs){
  if (cs==4)
    return 'V';
  if (cs==3)
    return 'T';
  if (cs==2)
    return 'BP';
  return 'N';
}    

// Simple method, as if it were typed in thru DOM
function sendChat (msg){
  document.getElementById ("mod_comm_input").value = msg;
  unsafeWindow.Chat.sendChat ();
}

// works well, but message is not echoed back to local client
Chat = {
  params : null,

  sendWhisper : function (msg, who, notify){
    this.params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    this.params.ctype = 3;
    this.params.name = who;
    this._sendit (msg, notify);
  },

  sendGlobal : function (msg, notify){
    this.params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    this.params.ctype = 1;
    this._sendit (msg, notify);
  },

  sendAlliance : function (msg, notify){
    this.params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
    this.params.ctype = 2;
    this._sendit (msg, notify);
  },

  _sendit : function (msg, notify){
    function strip(s) {
       return s.replace(/^\s+/, '').replace(/\s+$/, '');
    }
    this.params.comment = strip (msg);
    new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/sendChat.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: this.params,
      onSuccess: function(transport) {
        if (notify)
          notify ();
      },
      onFailure: function(transport) {
        if (notify)
          notify ();
      }
    });
  },
}

function doDefTrain (cityId, unitId, num, notify){
  var time = unsafeWindow.modal_walls_traintime(unitId, num);
  var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
  params.cid = cityId;
  params.type = unitId;
  params.quant = num;
  params.items = 0;
  new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/fortify.php" + unsafeWindow.g_ajaxsuffix, {
      method: "post",
      parameters: params,
      onSuccess: function (rslt) {
        if (rslt.ok) {
          unsafeWindow.seed.queue_fort["city" + cityId].push([unitId, num, rslt.initTS, parseInt(rslt.initTS) + time, 0, time, rslt.fortifyId]);
          if (notify != null)
            setTimeout (function (){notify(null);}, 500);
        } else {
          if (notify != null)
            setTimeout (function (){notify(rslt.errorMsg);}, 500);
        }
      },
      onFailure: function () {
        if (notify != null)
          notify(rslt.errorMsg);
      },
  });
}


function doTrain (cityId, unitId, num, notify){
  var time = unsafeWindow.modal_barracks_traintime(unitId, num);
  var params = unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams);
  params.cid = cityId;
  params.type = unitId;
  params.quant = num;
  params.items = 0;

  new MyAjaxRequest(unsafeWindow.g_ajaxpath + "ajax/train.php" + unsafeWindow.g_ajaxsuffix, {
    method: "post",
    parameters: params,
    onSuccess: function(rslt) {
      if (rslt.ok) {
        for (var i = 1; i < 5; i++) {
          unsafeWindow.seed.resources["city" + cityId]["rec" + i][0] = parseInt(unsafeWindow.seed.resources["city" + cityId]["rec" + i][0]) - parseInt(unsafeWindow.unitcost["unt" + unitId][i]) * 3600 * parseInt(num)
        }
        unsafeWindow.seed.citystats["city" + cityId].gold[0] = parseInt(unsafeWindow.seed.citystats["city" + cityId].gold[0]) - parseInt(unsafeWindow.unitcost["unt" + unitId][5]) * parseInt(num);
        unsafeWindow.seed.citystats["city" + cityId].pop[0] = parseInt(unsafeWindow.seed.citystats["city" + cityId].pop[0]) - parseInt(unsafeWindow.unitcost["unt" + unitId][6]) * parseInt(num);
        unsafeWindow.seed.queue_unt["city" + cityId].push([unitId, num, rslt.initTS, parseInt(rslt.initTS) + time, 0, time, null]);
        if (notify != null)
          setTimeout (function (){notify(null);}, 500);
      } else {
        if (notify != null){
          setTimeout (function (){notify(rslt.errorMsg);}, 500);
        }
      }
    },
    onFailure: function(o) {
      if (notify != null)
        notify(rslt.errorMsg);
    }
  });
}



/************  LIB classes/functions .... **************/
function getAbsoluteOffsets (e){
  ret = {left:0, top:0};
  while (e.offsetParent){
    if (e.style.position == 'absolute')
      break;
    ret.left += e.offsetLeft;
    ret.top += e.offsetTop;
    e = e.offsetParent;
  }      
  return ret;  
}

DebugTimer = {
  startTime : 0,
  start : function (){
    now = new Date();
    DebugTimer.startTime = now.getTime();
  },
  display : function (label, noReset){
    now = new Date();
    elapsed = now.getTime() - DebugTimer.startTime;
    logit (label +": "+ elapsed/1000);
    if (noReset===null || !noReset)
      DebugTimer.startTime = now.getTime();
  },
};

function debugPos  (e){
  return 'client - offset: '+ e.clientLeft +','+ e.clientTop +','+ e.clientWidth +','+ e.clientHeight
          +' - '+ e.offsetLeft +','+ e.offsetTop +','+ e.offsetWidth +','+ e.offsetHeight +' '+ e +' --OP--> '+ e.offsetParent;
}

function debugElement  (e){
  var x = unsafeWindow.Object.clone (e.wrappedJSObject);
  x.innerHTML = '';
  x.innerText = '';
  x.textContent = '';
  return inspect (x, 1, 1);
}     

function searchDOM (node, condition, maxLevel, doMult){
  var found = [];
  eval ('var compFunc = function (node) { return ('+ condition +') }');
  doOne(node, 1);
  if(!doMult){
    if (found.length==0)
      return null;
    return found[0];
  }
  return found;
  function doOne (node, curLevel){
    try {
      if (compFunc(node))
        found.push(node);
    } catch (e){
    }      
    if (!doMult && found.length>0)
      return;
    if (++curLevel<maxLevel && node.childNodes!=undefined)
      for (var c=0; c<node.childNodes.length; c++)
        doOne (node.childNodes[c], curLevel);
  }
}

function getClientCoords(e){
  if (e==null)
    return {x:null, y:null, width:null, height:null};
  var x=0, y=0;
  ret = {x:0, y:0, width:e.clientWidth, height:e.clientHeight};
  while (e.offsetParent != null){
    ret.x += e.offsetLeft;
    ret.y += e.offsetTop;
    e = e.offsetParent;
  }
  return ret;
}


function htmlTitleLine (msg){
  return '<TABLE width=100% cellspacing=0><TR><TD style="padding:0px" width=50%><HR></td><TD style="padding:0px">[ '+ msg +' ]</td><TD style="padding:0px" width=50%><HR></td></tr></table>';  
}


var WinManager = {
  wins : {},    // prefix : CPopup obj

  get : function (prefix){
    var t = WinManager;
    return t.wins[prefix];
  },
  
  add : function (prefix, pop){
    var t = WinManager;
    t.wins[prefix] = pop;
    if (unsafeWindow.cpopupWins == null)
      unsafeWindow.cpopupWins = {};
    unsafeWindow.cpopupWins[prefix] = pop;
  },
  
  delete : function (prefix){
    var t = WinManager;
    delete t.wins[prefix];
    delete unsafeWindow.cpopupWins[prefix];
  }    
}


// creates a 'popup' div
// prefix must be a unique (short) name for the popup window
function CPopup (prefix, x, y, width, height, enableDrag, onClose) {
  var pop = WinManager.get(prefix);
  if (pop){
    pop.show (false);
    return pop;
  }
  this.BASE_ZINDEX = 111111;
    
  // protos ...
  this.show = show;
  this.toggleHide = toggleHide;
  this.getTopDiv = getTopDiv;
  this.getMainDiv = getMainDiv;
  this.getLayer = getLayer;
  this.setLayer = setLayer;
  this.setEnableDrag = setEnableDrag;
  this.getLocation = getLocation;
  this.setLocation = setLocation;
  this.focusMe = focusMe;
  this.unfocusMe = unfocusMe;
  this.centerMe = centerMe;
  this.destroy = destroy;

  // object vars ...
  this.div = document.createElement('div');
  this.prefix = prefix;
  this.onClose = onClose;
  
  var t = this;
  this.div.className = 'CPopup '+ prefix +'_CPopup';
  this.div.id = prefix +'_outer';
  this.div.style.background = "#fff";
  this.div.style.zIndex = this.BASE_ZINDEX        // KOC modal is 100210 ?
  this.div.style.display = 'none';
  this.div.style.width = width + 'px';
  this.div.style.height = height + 'px';
  this.div.style.position = "absolute";
  this.div.style.top = y +'px';
  this.div.style.left = x + 'px';
  
  if (CPopUpTopClass==null)
    topClass = 'CPopupTop '+ prefix +'_CPopupTop';
  else
    topClass = CPopUpTopClass +' '+ prefix +'_'+ CPopUpTopClass;
    
  var m = '<TABLE cellspacing=0 width=100% height=100%><TR id="'+ prefix +'_bar" class="'+ topClass +'"><TD width=99% valign=bottom><SPAN id="'+ prefix +'_top"></span></td>\
      <TD id='+ prefix +'_X align=right valign=middle onmouseover="this.style.cursor=\'pointer\'" style="color:#fff; background:#333; font-weight:bold; font-size:14px; padding:0px 5px">X</td></tr>\
      <TR><TD height=100% valign=top class="CPopMain '+ prefix +'_CPopMain" colspan=2 id="'+ prefix +'_main"></td></tr></table>';
  document.body.appendChild(this.div);
  this.div.innerHTML = m;
  document.getElementById(prefix+'_X').addEventListener ('click', e_XClose, false);
  this.dragger = new CWinDrag (document.getElementById(prefix+'_bar'), this.div, enableDrag);
  
  this.div.addEventListener ('mousedown', e_divClicked, false);
  WinManager.add(prefix, this);
  
  function e_divClicked (){
    t.focusMe();
  }  
  function e_XClose (){
    t.show(false);
    if (t.onClose != null)
      t.onClose();
  }

  function focusMe (){
    t.setLayer(5);
    for (k in unsafeWindow.cpopupWins){
      if (k != t.prefix)
        unsafeWindow.cpopupWins[k].unfocusMe();
    }
  }
  function unfocusMe (){
    t.setLayer(-5);
  }
  function getLocation (){
    return {x: parseInt(this.div.style.left), y: parseInt(this.div.style.top)};
  }
  function setLocation (loc){
    t.div.style.left = loc.x +'px';
    t.div.style.top = loc.y +'px';
  }
  function destroy (){
    document.body.removeChild(t.div);
    WinManager.delete (t.prefix);
  }
  function centerMe (parent){
    if (parent == null){
      var coords = getClientCoords(document.body);
    } else
      var coords = getClientCoords(parent);
    var x = ((coords.width - parseInt(t.div.style.width)) / 2) + coords.x;
    var y = ((coords.height - parseInt(t.div.style.height)) / 2) + coords.y;
    if (x<0)
      x = 0;
    if (y<0)
      y = 0;
    t.div.style.left = x +'px';
    t.div.style.top = y +'px';
  }
  function setEnableDrag (tf){
    t.dragger.setEnable(tf);
  }
  function setLayer(zi){
    t.div.style.zIndex = ''+ (this.BASE_ZINDEX + zi);
  }
  function getLayer(){
    return parseInt(t.div.style.zIndex) - this.BASE_ZINDEX;
  }
  function getTopDiv(){
    return document.getElementById(this.prefix+'_top');
  }
  function getMainDiv(){
    return document.getElementById(this.prefix+'_main');
  }
  function show(tf){
    if (tf){
      t.div.style.display = 'block';
      t.focusMe ();
    } else {
      t.div.style.display = 'none';
    }
    return tf;
  }
  function toggleHide(t){
    if (t.div.style.display == 'block') {
      return t.show (false);
    } else {
      return t.show (true);
    }
  }
}

function CWinDrag (clickableElement, movingDiv, enabled) {
  var t=this;
  this.setEnable = setEnable;
  this.setBoundRect = setBoundRect;
  this.debug = debug;
  this.dispEvent = dispEvent;
  this.lastX = null;
  this.lastY = null;
  this.enabled = true;
  this.moving = false;
  this.theDiv = movingDiv;
  this.body = document.body;
  this.ce = clickableElement;
  this.moveHandler = new CeventMove(this).handler;
  this.outHandler = new CeventOut(this).handler;
  this.upHandler = new CeventUp(this).handler;
  this.downHandler = new CeventDown(this).handler;
  this.clickableRect = null;
  this.boundRect = null;
  this.bounds = null;
  this.enabled = false;
  if (enabled == null)
    enabled = true;
  this.setEnable (enabled);

  function setBoundRect (b){    // this rect (client coords) will not go outside of current body
    this.boundRect = boundRect;
    this.bounds = null;
  }

  function setEnable (enable){
    if (enable == t.enabled)
      return;
    if (enable){
      clickableElement.addEventListener('mousedown',  t.downHandler, false);
      t.body.addEventListener('mouseup', t.upHandler, false);
    } else {
      clickableElement.removeEventListener('mousedown', t.downHandler, false);
      t.body.removeEventListener('mouseup', t.upHandler, false);
    }
    t.enabled = enable;
  }

  function CeventDown (that){
    this.handler = handler;
    var t = that;
    function handler (me){
if (DEBUG_TRACE_DRAG) t.dispEvent ('eventDOWN', me);
      if (t.bounds == null){
        t.clickableRect = getClientCoords(clickableElement);
        t.bodyRect = getClientCoords(document.body);
        if (t.boundRect == null)
          t.boundRect = t.clickableRect;
if (DEBUG_TRACE_DRAG) logit ('Clickable rect: '+ inspect (t.clickableRect, 3, 1));
if (DEBUG_TRACE_DRAG) logit ('Body rect: '+ inspect (t.bodyRect, 3, 1));
if (DEBUG_TRACE_DRAG) logit ('Bound rect: '+ inspect (t.boundRect, 3, 1));
        t.bounds = {top:10-t.clickableRect.height, bot:t.bodyRect.height-25, left:40-t.clickableRect.width, right:t.bodyRect.width-25};
if (DEBUG_TRACE_DRAG) logit ("BOUNDS: "+ inspect (t.bounds, 8, 10));
      }
      if (me.button==0 && t.enabled){
        t.body.addEventListener('mousemove', t.moveHandler, true);
        t.body.addEventListener('mouseout', t.outHandler, true);
        t.lastX = me.clientX;
        t.lastY = me.clientY;
        t.moving = true;
      }
    }
  }

  function CeventUp  (that){
    this.handler = handler;
    var t = that;
    function handler (me){
if (DEBUG_TRACE_DRAG) t.dispEvent ('eventUP', me);
      if (me.button==0 && t.moving)
        _doneMoving(t);
    }
  }

  function _doneMoving (t){
if (DEBUG_TRACE_DRAG) logit ('doneMoving');
    t.body.removeEventListener('mousemove', t.moveHandler, true);
    t.body.removeEventListener('mouseout', t.outHandler, true);
    t.moving = false;
  }

  function CeventOut  (that){
    this.handler = handler;
    var t = that;
    function handler (me){
//t.dispEvent ('eventOUT', me);
      if (me.button==0){
        t.moveHandler (me);
      }
    }
  }

  function CeventMove (that){
    this.handler = handler;
    var t = that;
    function handler (me){
      if (t.enabled && !t.wentOut){
//t.dispEvent ('eventMOVE', me);
        var newTop = parseInt(t.theDiv.style.top) + me.clientY - t.lastY;
        var newLeft = parseInt(t.theDiv.style.left) + me.clientX - t.lastX;
        if (newTop < t.bounds.top){     // if out-of-bounds...
          newTop = t.bounds.top;
          _doneMoving(t);
        } else if (newLeft < t.bounds.left){
          newLeft = t.bounds.left;
          _doneMoving(t);
        } else if (newLeft > t.bounds.right){
          newLeft = t.bounds.right;
          _doneMoving(t);
        } else if (newTop > t.bounds.bot){
          newTop = t.bounds.bot;
          _doneMoving(t);
        }
        t.theDiv.style.top = newTop + 'px';
        t.theDiv.style.left = newLeft + 'px';
        t.lastX = me.clientX;
        t.lastY = me.clientY;
      }
    }
  }

  function debug  (msg, e){
    logit ("*************** "+ msg +" ****************");
    logit ('clientWidth, Height: '+ e.clientWidth +','+ e.clientHeight);
    logit ('offsetLeft, Top, Width, Height (parent): '+ e.offsetLeft +','+ e.offsetTop +','+ e.offsetWidth +','+ e.offsetHeight +' ('+ e.offsetParent +')');
    logit ('scrollLeft, Top, Width, Height: '+ e.scrollLeft +','+ e.scrollTop +','+ e.scrollWidth +','+ e.scrollHeight);
  }

  function dispEvent (msg, me){
    logit (msg + ' Button:'+ me.button +' Screen:'+ me.screenX +','+ me.screenY +' client:'+  me.clientX +','+ me.clientY +' rTarget: '+ me.relatedTarget);
  }
}

function inspect(obj, maxLevels, level, doFunctions){
  var str = '', type, msg;
  if(level == null)  level = 0;
  if(maxLevels == null) maxLevels = 1;
  if(maxLevels < 1)
      return 'Inspect Error: Levels number must be > 0';
  if(obj == null)
    return 'ERROR: Object is NULL\n';
  var indent = '';
  for (var i=0; i<level; i++)
    indent += '  ';
  for(property in obj) {
    try {
        type =  matTypeof(obj[property]);
        if (doFunctions==true && (type == 'function')){
          str += indent + '(' + type + ') ' + property + "[FUNCTION]\n";
        } else if (type != 'function') {
          str += indent + '(' + type + ') ' + property + ( (obj[property]==null)?(': null'):('')) +' = '+ obj[property] +"\n";
        }
        if((type=='object' || type=='array') && (obj[property] != null) && (level+1 < maxLevels))
          str += inspect(obj[property], maxLevels, level+1, doFunctions);  // recurse
    }
    catch(err) {
      // Is there some properties in obj we can't access? Print it red.
      if(typeof(err) == 'string') msg = err;
      else if(err.message)        msg = err.message;
      else if(err.description)    msg = err.description;
      else                        msg = 'Unknown';
      str += '(Error) ' + property + ': ' + msg +"\n";
    }
  }
  str += "\n";
  return str;
}

Array.prototype.compare = function(testArr) {
    if (this.length != testArr.length) return false;
    for (var i = 0; i < testArr.length; i++) {
        if (this[i].compare) {
            if (!this[i].compare(testArr[i])) return false;
        }
        if (this[i] !== testArr[i]) return false;
    }
    return true;
}
String.prototype.entityTrans = { '&':'&amp;', '<':'&lt;',  '>':'&gt;',  '\"':'&quot;' };
String.prototype.htmlEntities = function() {
  var ret = this.toString();
  for (k in this.entityTrans)
     ret  = ret.split(k).join(this.entityTrans[k]);
  return ret;
}

String.prototype.stripTags = function(){
  return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, '');
}

String.prototype.capitalize = function(){
  return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
}


function objectName (o){
  var s = o.toString();
  return s.substr(7,s.length-8);
}

function matTypeof (v){
  if (v == undefined)
    return 'undefined';
  if (typeof (v) == 'object'){
    if (!v)
      return 'null';
    else if (v.constructor.toString().indexOf("Array")>=0 && typeof(v.splice)=='function')
      return 'array';
    else return 'object';
  }
  return typeof (v);
}

function addCommasInt(n){
  nStr = parseInt(n) + '';
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(nStr)) {
    nStr = nStr.replace(rgx, '$1' + ',' + '$2');
  }
  return nStr;
}

function addCommas(nStr){
  nStr += '';
  x = nStr.split('.');
  x1 = x[0];
  x2 = x.length > 1 ? '.' + x[1] : '';
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(x1)) {
    x1 = x1.replace(rgx, '$1' + ',' + '$2');
  }
  return x1 + x2;
}

function addCommasWhole(nStr){
  nStr += '';
  x = nStr.split('.');
  x1 = x[0];
  x2 = x.length > 1 ? '.' + x[1] : '';
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(x1)) {
    x1 = x1.replace(rgx, '$1' + ',' + '$2');
  }
  return x1;
}
function htmlSelector (valNameObj, curVal, tags){
  m = [];
  m.push ('<SELECT');
  if (tags){
    m.push (' ');
    m.push (tags);
  }  
  for (k in valNameObj){
    m.push ('><OPTION ');
    if (k == curVal)
      m.push ('SELECTED ');
    m.push ('value="');
    m.push (k);
    m.push ('">');
    m.push (valNameObj[k]);
    m.push ('</option>');
  }
  m.push ('</select>');
  return m.join ('');

}


function unixTime (){
  return parseInt (new Date().getTime() / 1000) + unsafeWindow.g_timeoff;
}
function htmlOptions (a, curVal){
  m = '';
  for (k in a)
    m += '<OPTION value="'+ k +'"'+ (k==curVal?' SELECTED':'')  +'>'+ a[k] +'</option>';
  return m;
}
function getFunctionName (func){
  var name=/\W*function\s+([\w\$]+)\(/.exec(func);
  if (!name)
    return '';
  return name[1];
}

function findAllBetween (txt, find1, find2){
  var m = [];
  var last = 0;
  while ( (i1=txt.indexOf(find1, last))>=0 && (i2=txt.indexOf (find2, i1))>=0 ) {
    m.push (txt.substring(i1+find1.length, i2));
    last = i2 + find2.length;
  }
  return m;
}

function strUpTo (s, find){
  var i = s.indexOf(find);
  if (i > 0)
    return s.substr(0, i);
  return s;
}


/********
 Xd Xh
 Xh Xm
 Xm Xs
 Xs
********/
function timestrShort(time) {
  time = parseInt (time);
  if (time > 86400){
    var m = [];
    time /= 3600;
    m.push (parseInt(time/24));
    m.push ('T ');
    m.push (parseInt(time%24));
    m.push ('Std. ');
    return m.join ('');    
  } else
    return timestr (time);
}

/**********************
 part       full
 Xd Xh Xm   Xd Xh Xm Xs
 Xh Xm      Xh Xm Xs
 Xm Xs      Xm Xs
 Xs         Xs
**********************/
function timestr(time, full) {
  time = parseInt (time);
  var m = [];
  var t = time;
  if (t < 61)
    return  t + 's';
  if (t > 86400){
    m.push (parseInt(t/86400));
    m.push ('T ');
    t %= 86400;
  }  
  if (t>3600 || time>3600){
    m.push (parseInt(t/3600));
    m.push ('Std. ');
    t %= 3600;
  }  
  m.push (parseInt(t/60));
  m.push ('m');
  if (full || time<=3600 ){
    m.push (' ');
    m.push (t%60);
    m.push ('s');  
  }
  return m.join ('');
}

/************  LIB singletons .... **************/
// TODO: fix REopening window
var WINLOG_MAX_ENTRIES = 1000;     // TODO
var WinLog = {
  state : null,
  win: null,
  eOut : null,
  lastE : null,
  enabled : true,
  reverse : true,
  busy : false,
isOpening : false,

  open : function (){
    var t = WinLog;

    function eventButClear(){
      var t = WinLog;
      t.lastE = null;
      t.eOut.innerHTML ='';
    }
    function eventButReverse(){
      var t = WinLog;
      if (t.busy)
        return;
      t.busy = true;
      if (t.reverse){
        t.win.document.getElementById('wlRev').value= 'Top';
        t.reverse = false;
      } else{
        t.win.document.getElementById('wlRev').value= 'Bottom';
        t.reverse = true;
      }
      var n = t.eOut.childNodes.length;
      if (n < 2)
        return;
      for (i=n-2; i>=0; i--){
        t.eOut.appendChild (t.eOut.childNodes[i]);
      }
      t.busy = false;
    }
    
    if (!t.win || t.win.closed){
t.isOpening = true;  
// Firefox bug??? It appears as if a new thread is started on open, withOUT reusing same window
      t.win = window.open('', 'uwtrace', 'top=30,left=0,width=900,height=700,scrollbars=no,location=no,menubar=no,directories=no,status=no');
t.isOpening = false;
t.state = null;
    }
    
    if (t.state == null){
      t.win.document.body.innerHTML = '<STYLE>pre{margin:0px} hr{margin:3px; height:1px; border:0px; color:#cee; background-color:#cee}</style>\
        <BODY style="margin:0px; padding:0px; border:none">\
        <DIV id=winlogtop style="background-color:#d0d0d0; margin:0px; padding:0px; border:1px solid">\
        <INPUT id=wlClear type=submit value="Clear"> &nbsp; <INPUT id=wlRev type=submit value="Bottom"></div>\
        <DIV id=wlOut style="overflow-y:auto; height:100%; max-height:100%"></div></body>';
      t.win.document.getElementById('wlClear').addEventListener('click', eventButClear, false);
      t.win.document.getElementById('wlRev').addEventListener('click', eventButReverse, false);
      t.eOut =  t.win.document.getElementById('wlOut');
      t.lastE = null;
      t.state = 1;
    }
  },

  
  writeText : function (msg){
    WinLog.write (msg.htmlEntities());
  },
  
  write : function (msg){
    var t = WinLog;
    if (!t.enabled || t.isOpening)
      return;
    t.open();
    var te = document.createElement('pre');
    var now = new Date();
    var m = [];
    var millis = now.getMilliseconds();
    m.push (now.toTimeString().substring (0,8));
    m.push ('.');
    if (millis<100)
      m.push('0');
    if (millis<10)
      m.push('0');
    m.push(millis);
    m.push (': ');
    m.push (msg);
    te.innerHTML = m.join('');

    if (t.reverse){
      if (t.lastE == null){
        t.eOut.appendChild(te);
        t.lastE = te;
      } else {
        t.eOut.insertBefore(te, t.lastE);
      }
      var hr = document.createElement('hr');
      t.eOut.insertBefore(hr, te);
      t.lastE = hr;
    } else {
      t.eOut.appendChild(te);
      t.eOut.appendChild(document.createElement('hr'));
    }
  },
};

ptStartup ();

